Passport.js optional authentication

后端 未结 2 705
礼貌的吻别
礼貌的吻别 2021-01-07 23:54

Is there an optional authentication middleware from Passport.js?

Let\'s say I have a route, /api/users. I want to give just a list of users to the publi

2条回答
  •  灰色年华
    2021-01-08 00:41

    Might be late now, but there's an anonymous Passport strategy to allow exactly this. That way the public routes can either take authentication or not, but when they do you'll still have all of the information associated with the authenticated user. Check it out here: https://github.com/jaredhanson/passport-anonymous

提交回复
热议问题