Skip to content

[v1.x] Add subject and claims to AccessToken#2690

Merged
maxisbey merged 1 commit into
v1.xfrom
v1/auth-access-token-subject
May 26, 2026
Merged

[v1.x] Add subject and claims to AccessToken#2690
maxisbey merged 1 commit into
v1.xfrom
v1/auth-access-token-subject

Conversation

@maxisbey
Copy link
Copy Markdown
Contributor

v1.x backport of #2686.

Summary

Adds optional subject and claims fields to AccessToken so token verifiers can surface the resource owner (sub) and any additional claims to request handlers, and adds subject to AuthorizationCode and RefreshToken so the value can be carried through code-for-token exchange and refresh.

The simple-auth example is updated to thread the subject from login through the introspection response and back into the verifier; the integration test exercises the full code → token → refresh → load chain.

Closes #1038. Supersedes #2209 and #1517 — see #2686 for context. Thanks to @thomasst, @yukuanj, and @shivama205 for the prior work.

Differences from #2686

The Context.client_id docstring clarification lands in fastmcp/server.py rather than mcpserver/context.py; the integration test threading lands in tests/server/fastmcp/auth/test_auth_integration.py. Otherwise identical.

Breaking changes

None. All new fields are optional with None defaults.

AI Disclaimer

Adds optional `subject` and `claims` fields to `AccessToken` so token
verifiers can surface the resource owner (`sub`) and any additional
claims to request handlers. `subject` is also added to
`AuthorizationCode` and `RefreshToken` so the value can be carried
through code-for-token exchange and refresh.

The simple-auth example threads the subject from login through the
introspection response and back into the verifier; the integration
test exercises the full code → token → refresh → load chain.

v1.x backport of #2686. Closes #1038.

Reported-by: Thomas Steinacher <@thomasst>
Reported-by: Yukuan Jia <@yukuanj>
Reported-by: Shivam Aggarwal <@shivama205>
@maxisbey maxisbey marked this pull request as ready for review May 26, 2026 14:00
@maxisbey maxisbey requested review from Kludex and pcarleton May 26, 2026 14:20
@maxisbey maxisbey merged commit 1abcca2 into v1.x May 26, 2026
22 checks passed
@maxisbey maxisbey deleted the v1/auth-access-token-subject branch May 26, 2026 14:49
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