Skip to content
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 support for additional header claims in signJWT() function #5

Merged
merged 1 commit into from
Jul 22, 2024
Merged

Add support for additional header claims in signJWT() function #5

merged 1 commit into from
Jul 22, 2024

Conversation

cwirving
Copy link
Contributor

Related to issue #4, this PR opens up the ability by callers to provide additional header claims when creating/signing a JWT. I originally was going to limit it to the kid claim, but then realized that others may have similar but different needs, so I made it possible to set any header claims:

In addition to providing token body claims as part of the function signature, the options provided to signJWT() include additional header claims that can augment (or overwrite) the standard JWT header claims.

Since additional header claims are relatively useless if there is no way to read the JWT header (JOSE header, to be precise), I added a unsafeParseJOSEHeader() function that can be used by token recipients to read the full header and determine the value of the kid claim and choose the correct public key to pass to validateJWT().

Also added a couple more tests making it clear that validateJWT() does not trust the algorithm claim in the JWT header.

In addition to providing token body claims, the options provided to `signJWT()` include additional header claims that can augment (or overwrite) the standard JWT header claims.

Also added a couple more tests making it clear that `validateJWT()` does not trust the algorithm claim in the JWT header.
@Pinta365 Pinta365 merged commit 51da4ac into cross-org:main Jul 22, 2024
2 checks passed
@cwirving cwirving deleted the jwt-kid branch July 22, 2024 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants