Skip to content

Next-Auth token as authentication on multiple apps? #5603

Answered by hems
hems asked this question in Help
Discussion options

You must be logged in to vote

The solution i have found is to sign the JWT with an asymmetric key and then share the PUBLIC KEY with the other APIS this way I can verify the information was signed by my server ( jwt issuer which holds the private key ).

There is a need to override the encode / decode methods for JWT on next-auth in order to use RS256 instead of the default algorithm.

From that point I would be able to send the encrypted JWT token to another HTTP API ( via HTTP HEADER ) and verify it on the HTTP API which will only need to know the PUBLIC KEY in order to verify the signature ( the private key never leaves my jwt issuing environment ) thus being able to verify the signature even if offline ( i.e. no ext…

Replies: 4 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@robertwt7
Comment options

@hems
Comment options

@robertwt7
Comment options

@hems
Comment options

Answer selected by hems
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
question Ask how to do something or how something works
5 participants
Converted from issue

This discussion was converted from issue #5600 on October 19, 2022 20:23.