Skip to content

feat: make sign typ whitelist configurable via set_typ_whitelist#72

Open
jattsson wants to merge 1 commit into
cdbattags:masterfrom
jattsson:feature/issue-69-typ-allowlist
Open

feat: make sign typ whitelist configurable via set_typ_whitelist#72
jattsson wants to merge 1 commit into
cdbattags:masterfrom
jattsson:feature/issue-69-typ-allowlist

Conversation

@jattsson
Copy link
Copy Markdown

@jattsson jattsson commented May 26, 2026

Summary

  • Replaces the hard-coded JWT/JWE check in sign with a configurable whitelist, mirroring set_alg_whitelist in shape and naming.
  • Default whitelist now accepts JWT, JWE, plus the RFC-registered +jwt structured-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).
  • Callers can call jwt:set_typ_whitelist({...}) to replace the defaults, {} to reject every typ value, or nil to 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/load remain permissive on header.typ as before. Callers needing typ enforcement on the verify side can use the existing __jwt validator 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 in t/sign-verify.t).
  • New tests cover: default whitelist accepts at+jwt and dpop+jwt; rejects unknown typ; set_typ_whitelist replaces defaults; set_typ_whitelist(nil) disables validation; set_typ_whitelist({}) rejects everything including JWT.
  • Pre-push diff against origin/master was clean — no overlap with any pending master work.

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
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.

1 participant