I have a NodeJs REST service by calling him - NodeRest on my side and AngularJs on my side of the interface.
NodeRest is supposed to be used with mobile applications, as well as with web applications, in my case it is an AngularJs application.
The NodeRest architecture should solve the following problem when using PassportJs:
The server should not redirect the user to facebook for authorization when
app.get('/auth/facebook', passport.authenticate('facebook'));
.
In case he redirects it, the client will not receive anything, because the callback URL is associated with NodeRest httpL // noderest / facebook / callback. Instead, it should provide uri redirection, so I can send it back to the client (angularJs, mobile, etc.). Smth like this:
app.get('/auth/facebook', passport.authenticate('facebook', function(redirectUri){
I decided to use socket.io as a communication channel in the authorization process.
Customer:
var socket = io.connect(baseUrl); socket.on('auth:facebook:callback:getCalled', function (data) {
The client will be responsible for redirecting to facebook / twitter, etc., in order to obtain user authorization. Immediately after this, the user will be redirected to the callback URL.
Server:
app.get('/auth/facebook/callback', function(){ passport.authenticate('facebook', { successRedirect: '/', failureRedirect: '/login' })
The general idea of ββall this is to get permission from various client applications (mobile, web applications, desktop computers, etc.). The client should only be able to redirect uri to oauth2 providers (facebook, twitter, etc.) and redirect it to this uri by itself. NodeRest will take care of the next steps (i.e., it will handle the callback and notify the client).
I don't know if this is a good solution I'm working on, so any feedback would be more than helpful. I would appreciate any feedback.
Thanks in advance, Julian