Skip to content

Name the ID-JAG JWT type once - #7070

Merged
jhrozek merged 1 commit into
mainfrom
idjag-pr-1
Nov 6, 2026
Merged

jhrozek merged 1 commit into
mainfrom
idjag-pr-1

Conversation

@jhrozek

@jhrozek jhrozek commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Summary

ID-JAG issuance through token exchange (#6898) needs the ID-JAG JOSE typ value, oauth-id-jag+jwt, in more places. The next change refuses that typ at the access-token and subject-token validators. Today the value is a private constant in jwt_bearer_handler.go, a second private constant in the vMCP XAA strategy, and string literals in tests. This PR defines it once before more code depends on it.

  • Add oauthproto.JWTTypeIDJAG next to the existing oauthproto.TokenTypeIDJAG URN.
  • Use it in the JWT-bearer and ID-JAG handlers, in the vMCP XAA strategy's typ check, and in the tests that sign ID-JAG assertions.
  • Move the tokenexchange package comment from validator.go to a new doc.go, and rewrite it to list what the package now holds: the RFC 8693 handlers, the RFC 7523 JWT-bearer and ID-JAG redemption handlers, and the trust layer they share.

Ref #6898

Type of change

  • Refactoring (no behavior change)

Test plan

  • Unit tests (task test)
  • Linting (task lint: 0 issues)

Changes

File Change
pkg/oauthproto/constants.go New JWTTypeIDJAG constant
pkg/authserver/server/tokenexchange/jwt_bearer_handler.go, id_jag_handler.go Drop the private idJAGJWTType; use the shared constant
pkg/vmcp/auth/strategies/xaa.go Drop the local copy; use the shared constant
pkg/authserver/server/tokenexchange/doc.go, validator.go Package comment moved and rewritten
*_test.go (7 files) Use the constant instead of string literals

Does this introduce a user-facing change?

No. The value is the same, and every comparison that uses it is unchanged.

The ID-JAG typ value was spelled as a string literal in several
places, and the vMCP XAA strategy kept its own private copy. A later
change checks this value at access-token and subject-token
validators, so it needs one shared definition. The constant moves to
oauthproto next to the ID-JAG token type URN, and both the auth
server and vMCP use it.

The tokenexchange package comment moves to doc.go and now says what
the package holds: the RFC 8693 handlers, the RFC 7523 redemption
handlers and the trust layer they share.

Ref: #6898

Co-authored-by: Mecatl <[email protected]>
@github-actions github-actions Bot added the size/XS Extra small PR: < 100 lines changed label Nov 6, 2026
@codecov

codecov Bot commented Nov 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.85%. Comparing base (01f96bf) to head (937a175).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7070      +/-   ##
==========================================
- Coverage   80.90%   80.85%   -0.06%     
==========================================
  Files         864      864              
  Lines       88634    88633       -1     
==========================================
- Hits        71709    71660      -49     
- Misses      16920    16968      +48     
  Partials        5        5              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rdimitrov rdimitrov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving: a behaviour-neutral consolidation of the ID-JAG typ value into one shared constant.

Design: pkg/oauthproto already owns the protocol constants shared by the authserver and vMCP, so JWTTypeIDJAG belongs next to TokenTypeIDJAG. Every Go comparison site now uses it (JWT-bearer and ID-JAG handler routing, CanSkipClientAuth, the assertion-type allowlist, and the vMCP XAA check), and no code literal remains. The value is byte-identical and the comparisons keep their semantics (exact match on the server, EqualFold in vMCP), so upgrades see no change. The old constant was unexported, so nothing public is removed.

Note for the follow-up that will refuse this typ in the access-token/subject-token validators: the server compares typ by exact match, while xaa.go ignores case. typ is a media type, so it compares case-insensitively and may carry an application/ prefix. An exact-match refusal list could be bypassed with OAuth-ID-JAG+JWT or application/oauth-id-jag+jwt. A small normalising helper next to this constant in oauthproto (lowercase, strip application/) would close that before it matters. The current allowlist fails closed, so this PR is not affected.

🤖 Reviewed with Claude Code

@jhrozek
jhrozek merged commit 3738fc9 into main Nov 6, 2026
48 checks passed
@jhrozek
jhrozek deleted the idjag-pr-1 branch November 6, 2026 19:15
@github-actions github-actions Bot mentioned this pull request Nov 10, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants