Skip to content

fix(server): type access tokens at+jwt for clients with an ID-JAG policy - #5179

Merged
nabokihms merged 4 commits into
dexidp:masterfrom
aeoess:fix/idjag-id-token-marker
Nov 17, 2026
Merged

nabokihms merged 4 commits into
dexidp:masterfrom
aeoess:fix/idjag-id-token-marker

Conversation

@aeoess

@aeoess aeoess commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Fixes #5177 for newly issued access tokens by adding a distinct JWT typ header for clients with an ID-JAG policy. Previously issued untyped tokens remain an exception until they expire.

What this PR does / why we need it

Dex currently signs access tokens with ID token claims. Without a way to distinguish the two token types, an ID-JAG exchange can accept an access token as an identity assertion.

This change:

  • Signs access tokens with typ: at+jwt for clients that have idJAGPolicies. The access tokens of every other client and all ID tokens remain unchanged.
  • Allows userinfo and introspection to verify typed access tokens.
  • Rejects newly issued access tokens from ID-JAG clients when supplied as ID-JAG subject tokens.
  • Adds tests for token typing per client, KeySet typ handling, introspection and userinfo with a typed token, and the ID-JAG rejections.

An earlier regression run on db226a7 returned HTTP 200 where HTTP 400 was expected.

Closes #5177

Special notes for your reviewer

  • Only a client with a policy can use the exchange. An untyped access token of another client is refused by the existing audience and azp checks in VerifyIDToken. A test covers the single-audience case and the cross-client case where the policy client is among the audiences.
  • The change adds token typing without changing the access token claims. It does not implement the complete RFC 9068 JWT access token profile.
  • An untyped access token issued to a client before the upgrade, or before the client got a policy, may still be accepted by ID-JAG until it expires. ID-JAG has not shipped in a release.
  • Resource servers that verify the access tokens of an ID-JAG client directly will see the typ header. For those clients the authorization and logout endpoints also stop accepting access tokens supplied as id_token_hint.
  • go test ./server/... ./storage/... and golangci-lint run ./... pass locally.

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

Thanks for the quick fix! A dex-specific claim in every ID token is visible to all OIDC clients, and once it ships we have to keep it. Could you go with typ: at+jwt on access tokens instead (RFC 9068)?

SignWithType already exists for ID-JAGs, and KeySet rejects any typ other than JWT, so VerifyIDToken refuses a typed access token without new checks. Userinfo and introspection verify access tokens through the same KeySet, so they'll need to accept at+jwt. Untyped access tokens issued before the upgrade would still pass until they expire, and that's fine since ID-JAG hasn't been released yet.

…ect_token

Dex signs access tokens with ID token claims, so VerifyIDToken accepted a dex access token as the Identity Assertion of an ID-JAG request. Access tokens are now signed with typ at+jwt (RFC 9068). The KeySet already refuses any typ other than JWT, so VerifyIDToken refuses them without a new check. Userinfo and introspection set KeySet.AcceptAccessTokens to keep accepting them.

Refs dexidp#5177

Signed-off-by: Tymofii Pidlisnyi <tima@aeoess.com>
@aeoess
aeoess force-pushed the fix/idjag-id-token-marker branch from 96bd44a to 0308a5e Compare November 17, 2026 06:54
@aeoess aeoess changed the title fix(server): require an ID token marker on the ID-JAG subject_token fix(server): distinguish access tokens with at+jwt Nov 17, 2026
@aeoess

aeoess commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

@nabokihms Updated the fix to use typ: at+jwt instead of the private claim. Userinfo and introspection now accept typed access tokens, while ID-JAG rejects them. Tests and lint pass locally.

One detail worth confirming: Dex still uses its existing access token claims, so this adds the RFC 9068 header without implementing the full profile, including its required client_id claim. Is that acceptable for this fix?

The id_token_hint paths will also stop accepting access tokens, which seems correct since they require ID tokens.

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

Thanks, the typed token works. One problem I missed when suggesting it: Spring Security resource servers reject typ: at+jwt by default (Nimbus only accepts JWT or no typ), so this breaks anyone who verifies dex access tokens with a stock NimbusJwtDecoder. Probably there are more.

Only a client with an ID-JAG policy can exchange its own access token, so could you type access tokens as at+jwt only for clients that have idJAGPolicies? Everyone else keeps today's format, and the KeySet changes stay as they are. On your client_id question: with typing limited to ID-JAG clients I'm fine without the full RFC 9068 profile for now.

…G policy

Signed-off-by: Tymofii Pidlisnyi <tima@aeoess.com>
@aeoess aeoess changed the title fix(server): distinguish access tokens with at+jwt fix(server): type access tokens at+jwt for clients with an ID-JAG policy Nov 17, 2026
@aeoess

aeoess commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

@nabokihms Updated in 43e55ae. Access tokens now use at+jwt only for clients with idJAGPolicies. Other clients retain the existing format, and the KeySet changes remain.

Tests cover rejection of another client's untyped access token, including when the policy client appears among its audiences. Tokens issued to a client before its policy was enabled remain untyped and may still be accepted by ID-JAG until they expire.

Signed-off-by: maksim.nabokikh <max.nabokih@gmail.com>

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

Thanks, LGTM!

@nabokihms nabokihms added the release-note/bug-fix Release note: Bug Fixes label Nov 17, 2026
@nabokihms
nabokihms merged commit 9975427 into dexidp:master Nov 17, 2026
9 checks passed
kuangruan pushed a commit to kuangruan/dex that referenced this pull request Nov 25, 2026
10 commits since 60f28dd: ID-JAG audience binding and auth_time, the
allowedGroups enforcement fix, ent blocked_until NULL handling, api
username validation, LDAP startTLS port default, implicit/hybrid fragment
encoding, and connector fixes. No changes are proposed upstream.

* 'master' of https://github.com/dexidp/dex:
  feat(oauth2): let an ID-JAG policy set the client's ID at each audience (dexidp#5181)
  feat(oauth2): carry auth_time from the subject token into the ID-JAG (dexidp#5180)
  fix(connector/github): return UserNotInRequiredGroupsError when user lacks org or team access (dexidp#5100)
  fix(storage/ent): store an unset blocked_until as NULL (dexidp#5163)
  fix(api): require a username in CreatePassword (dexidp#5162)
  fix(ldap): default to port 389 when startTLS is set (dexidp#5184)
  fix(server): don't double-encode the implicit and hybrid fragment (dexidp#5183)
  fix(oidc)!: enforce allowedGroups when insecureEnableGroups is unset (dexidp#5185)
  feat(server): allow starting without connectors when the connectors API is enabled (dexidp#5061)
  fix(server): type access tokens at+jwt for clients with an ID-JAG policy (dexidp#5179)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/bug-fix Release note: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ID-JAG token exchange accepts a Dex access token as an ID token

2 participants