-
Notifications
You must be signed in to change notification settings - Fork 7
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
JW*
Decode
#43
JW*
Decode
#43
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious, what are the cases where you needs access to claims before verifying? There's some higher precedence validation to do?
Actually I'm not sure we have run into that situation, @mistermoe am I forgetting something? I think this is a combination of things:
|
Overview
Collaborative effort with @KendallWeihe to split
Verify
into two distinct functionsDecode
andVerify
Important
Most of the code changes in this PR are from moving things around. not much net new logic was added
Rationale
we've run into multiple scenarios where we need to:
In order to access claims within a JWT the caller currently has to do this:
The above code ends up making it such that callers have to know more details than they have to about jwt details. further, if they've already verified the jwt, the claims are now being decoded twice.
Changes
In order to remedy the above, this PR splits decoding and verifying into two distinct steps while still providing a single function call if desired
JWT
Approach 1
This approach requires the caller to first decode the JWT, perform whatever business logic is needed and then optionally call verify when desired
Approach 2
This allows to caller to call verify and then decide to perform additional logic using the claims within a JWT depending on the result of verification
JWS
the
jws
API surface is identical tojwt
Approach 1
Approach 2