feat: make sign typ whitelist configurable via set_typ_whitelist#72
Open
jattsson wants to merge 1 commit into
Open
feat: make sign typ whitelist configurable via set_typ_whitelist#72jattsson wants to merge 1 commit into
jattsson wants to merge 1 commit into
Conversation
The hard-coded JWT/JWE check in sign rejected RFC-registered typ values
like at+jwt (RFC 9068) and dpop+jwt (RFC 9449). Introduce
set_typ_whitelist mirroring set_alg_whitelist, seeded with the eight
RFC-aligned defaults. Callers can replace the allowlist, pass {} to
reject everything, or pass nil to disable typ validation entirely.
Refs cdbattags#69
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
signwith a configurable whitelist, mirroringset_alg_whitelistin shape and naming.JWT,JWE, plus the RFC-registered+jwtstructured-syntax values:at+jwt(RFC 9068),dpop+jwt(RFC 9449),token-introspection+jwt(RFC 9701),client-authentication+jwt(draft-7523bis),secevent+jwt(RFC 8417),logout+jwt(OIDC Back-Channel Logout).jwt:set_typ_whitelist({...})to replace the defaults,{}to reject every typ value, ornilto disable typ validation entirely.Strict loosening — no input that worked before fails now; only previously-rejected RFC typ values now sign successfully. The check still only runs during
sign;verify/loadremain permissive onheader.typas before. Callers needing typ enforcement on the verify side can use the existing__jwtvalidator mechanism (documented in the README under Verification).Refs #69
Test plan
./ci— all 886 tests pass (868 previously + 18 new assertions from 6 TEST blocks int/sign-verify.t).at+jwtanddpop+jwt; rejects unknown typ;set_typ_whitelistreplaces defaults;set_typ_whitelist(nil)disables validation;set_typ_whitelist({})rejects everything includingJWT.origin/masterwas clean — no overlap with any pending master work.