Skip to content

Can Passport authentication and JWT be used together? #7772

Answered by zjjdes
zjjdes asked this question in Q&A
Discussion options

You must be logged in to vote

I managed to implement both passport strategies and JWT authentication and it seems to be working. I modified thirdPartyCallback() in loopback4-example-passport-login/src/controllers/oauth2.controller.ts to the following to mimic passportConfigurator.configureProvider() in LB3 which sends the access token and userId as Cookies:

  @oAuth2InterceptExpressMiddleware()
  @get('/auth/{provider}/callback')
  async thirdPartyCallBack(
    @param.path.string('provider') provider: string,
    @inject(SecurityBindings.USER) user: UserProfile,
    @inject(RestBindings.Http.REQUEST) request: RequestWithSession,
    @inject(RestBindings.Http.RESPONSE) response: Response,
  ) {
    const userId = user.p…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by zjjdes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant