-
-
Notifications
You must be signed in to change notification settings - Fork 171
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
feat: introduce getClaims method to verify asymmetric JWTs #1030
base: master
Are you sure you want to change the base?
Conversation
// try fetching from cache | ||
jwk = this.jwks.keys.find((key) => key.kid === kid) | ||
if (jwk) { | ||
return jwk | ||
} |
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.
It's important to have a process to clear-out entries from the cache according to the cache headers sent in the response. If this is used in a long-running Node server, and the JWT keys get rotated, the new keys will never be fetched.
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.
it will because when a new JWT needs to be validated, there will be a cache miss, which would trigger getClaims
to fetch the latest JWKS
data: { | ||
claims: payload, | ||
}, |
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.
Either return payload
as data
or include more information, such as:
data: { | |
claims: payload, | |
}, | |
data: { | |
claims: payload, | |
header, | |
signature, | |
}, |
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.
hmm why? the intention behind nesting it in claims
is to be consistent with the response structure for getUser
and getSession
2e4ce9a
to
a26e5dc
Compare
What kind of change does this PR introduce?
getClaims
supports verifying JWTs (both asymmetric and symmetric) and returns the entire set of claims in the JWT payload