fastmcp/tests/server/auth
Pierre Audonnet a57f1c8b20
Add subject field to AccessToken initialization (#4267)
* Add subject field to AccessToken initialization

Fixes #4266

Add `subject` property to the AccessToken.

```python
        return AccessToken(
            token=access_token_as_dict["token"],
            client_id=access_token_as_dict["client_id"],
            scopes=access_token_as_dict["scopes"],
            subject=access_token_as_dict["subject"],
            # Optional fields
            expires_at=access_token_as_dict.get("expires_at"),
            resource=access_token_as_dict.get("resource"),
            claims=access_token_as_dict.get("claims") or {},
        )
```

* Populate AccessToken.subject across all token verifiers

Closes #4266. get_access_token().subject was always None: the SDK's
AccessToken.subject wasn't carried into FastMCP's AccessToken by the
dependency-layer conversion, and none of the built-in TokenVerifiers
(JWT, introspection, and the OAuth-provider verifiers for Discord,
Clerk, Google, WorkOS, HuggingFace, GitHub, and Cognito) populated it
from the sub claim/field they already extract.

---------

Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2026-07-18 21:15:13 -04:00
..
oauth_proxy Add server-side identity assertion (SEP-990 ID-JAG) (#4483) 2026-07-18 19:52:15 -04:00
providers Add subject field to AccessToken initialization (#4267) 2026-07-18 21:15:13 -04:00
__init__.py Add WorkOS and Azure OAuth providers (#1550) 2025-08-20 16:22:03 -04:00
test_auth_provider.py Migrate to MCP SDK v2.0.0b2 (httpx2) (#4503) 2026-07-18 15:12:47 -04:00
test_authorization.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_cimd.py Stabilize upgraded ty checks (#4526) 2026-07-17 17:46:53 -04:00
test_cimd_validators.py Split large test files to comply with loq line limit (#3328) 2026-02-28 11:21:11 -05:00
test_debug_verifier.py Add DebugTokenVerifier with custom sync/async validation (#2296) 2025-10-31 10:38:01 -04:00
test_enhanced_error_responses.py Include scopes in auth challenges (#4527) 2026-07-18 20:53:52 -04:00
test_jwt_issuer.py Migrate auth JWTs to joserfc (#4221) 2026-05-23 09:29:04 -04:00
test_jwt_provider.py Add subject field to AccessToken initialization (#4267) 2026-07-18 21:15:13 -04:00
test_jwt_provider_bearer.py Migrate to MCP SDK v2.0.0b2 (httpx2) (#4503) 2026-07-18 15:12:47 -04:00
test_multi_auth.py Include scopes in auth challenges (#4527) 2026-07-18 20:53:52 -04:00
test_oauth_consent_flow.py Reject dot-segments in redirect URI allowlist matching (#3963) 2026-04-17 17:49:25 -04:00
test_oauth_consent_page.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_oauth_mounting.py Migrate to MCP SDK v2.0.0b2 (httpx2) (#4503) 2026-07-18 15:12:47 -04:00
test_oauth_proxy_redirect_validation.py Block unsafe OAuth redirect schemes (#4419) 2026-07-05 17:16:10 -04:00
test_oauth_proxy_storage.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_oidc_proxy.py Migrate to MCP SDK v2.0.0b2 (httpx2) (#4503) 2026-07-18 15:12:47 -04:00
test_oidc_proxy_token.py fix: use intent-based flag for OIDC scope patch in load_access_token (#3465) 2026-03-13 17:59:03 -04:00
test_redirect_validation.py Block unsafe OAuth redirect schemes (#4419) 2026-07-05 17:16:10 -04:00
test_remote_auth_provider.py Include scopes in auth challenges (#4527) 2026-07-18 20:53:52 -04:00
test_ssrf_protection.py Migrate to MCP SDK v2.0.0b2 (httpx2) (#4503) 2026-07-18 15:12:47 -04:00
test_static_token_verifier.py Add subject field to AccessToken initialization (#4267) 2026-07-18 21:15:13 -04:00