-
Notifications
You must be signed in to change notification settings - Fork 125
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
How to chain multiple jwt auth strategies #195
Comments
@Jiropole good question are you able to share some |
Before I start dumping typical code, just a bit more context. I think my confusion stems from not understanding how to use the key function. I believe I have a low-tech version of what Stongo was doing in #120. But I'm not clear how to get the original token passed to my keyfunc, since until I can run jwt.verify() with all (both) my keys, decoding will fail. At a higher level, this is to secure an API server that serves multiple Auth0 clients, each one sending tokens signed with a different secret. So, as to what I've tried:
So, this is the tree I'm trying to bark up, something like this:
|
Ah, I see the token is available immediately in |
Ok! I think I get it now (better slow than never). If you have a moment, could you verify this is a secure approach to variable-key JWT validation?
|
Sorry, this version's easier on the eyes:
|
@Jiropole yeah, that sounds like a good approach. Provided the client is only passing one token at any given time. 👍 |
Thanks very much @nelsonic; sorry for the noise. Hopefully this can help someone else. |
@Jiropole not at all! you're very welcome. glad we can help! ⭐ |
@Jiropole Started looking for similar solution today so you've already helped at least one person. Thanks 👍 |
@Jiropole How does your route look ? I cant get this working |
@bujardeari My routes mainly rely on the |
This isn't an issue per se, but I'm struggling like mad to find a solution. I have two types of clients that each have their own signing key. I need to try two jwt strategies in a row; if either of them match, the client should be authenticated.
However, this is not how Hapi's auth system works. If the first strategy fails to decode the token, it stops the chain and the second strategy is never called. I looked at #120 and #130 as they seemed similar, but I wasn't able to find a way to use
verifyFunc
to achieve the desired behavior.Basically, I need the first strategy to act like "try" and the second act like "required" but I can't figure out how to achieve this. Any ideas would be most appreciated! Sorry if this isn't exactly the right forum for the question, but seems someone must have encountered this use case before...
The text was updated successfully, but these errors were encountered: