-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using multiple passports #286
Comments
Some update - two different instances of the passport have been created using:
However, the next problem is that So how this could be fixed? |
Hi, For your 2nd passport instance roomPassport, if you want to be able to work with
|
for me, I want to use passport to authenticate clients and users. A user could log in using, say, Local strategy, using a client that would authenticate through Bearer strategy. I guess using the |
Hello everyone, If you would like the multiple passports to be used on different routes (and do not need both 'user' and 'room' to ever be simultaneously present in the same request handler), you can solve this issue by using multiple express.Router() objects, something like this: var roomRouter = express.Router(); var roomPassport = new Passport(); roomRouter.use(roomPassport.initialize({ userProperty: 'room'}); roomRouter.get('/rooms/...', roomPassport.authenticate(), roomRequestHandler); // and finally |
@cstavaru how do I authenticate each instance differently |
Hi there,
Suppose I need two different passports within one express application (e.g. user & room).
So I define two separate vars:
then, I initialize them with separate passport strategies:
the last step is to set them as Express middleware:
however, if I did it like this, in fact
roomPassport
overridespassport
and instead of having two objects -req.user
andreq.room
, I have got just onereq.room
but initialized with user data.It is important to mention that each passports (user or room) could authenticate independently from each other, i.e. there is a scenario where both objects
req.user
andreq.room
have to exist.How to resolve this?
The text was updated successfully, but these errors were encountered: