-
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
Add jwt.DecodeJWTClaims function #24
Conversation
Created an issue for the additional idea #25 |
nonce := "abcd123" | ||
claims := jwt.Claims{ | ||
Issuer: did.ID, | ||
Misc: map[string]interface{}{"c_nonce": nonce}, |
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.
interface{}
still works, but there's an alias for it now which is much more convenient: any
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.
IMO I prefer the language-native way of interface
... less convenient but more clear (at least to newbies)
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.
oh nice @alecthomas i had no idea about the alias
@KendallWeihe thoughts on renaming both |
Yeah nice, agreed! Done ✅ |
Overview
Given the developer has a JWT, and they extract the base64 URL encoded claims, they can call this function to decode into the
Claims
typeUsage
Additional Ideas
I followed the same pattern as we have with
jws.DecodeJWSHeader()
from here. But, we may want to go a add another layer here. Namely, the developer consuming this library (let's call them Alice), will likely have a full signed JWT string (which may originate from ourjwt.Sign()
function). And Alice may want both the headers & the claims (often times specs such as OID4VCI have verification rulesets which include both the header & the claims).Rather than having the developer first do this...
...we may want to embed that in a function, as well as also executing a call to
jwt.Verify()
. I originally had the idea that we could create a function like this...@mistermoe what do you think of that idea ☝️ We can open a ticket & copy/paste this in if we like it.