fastmcp/tests/server/auth
Jeremiah Lowin 52feff6878
Transparently refresh upstream token in OAuthProxy.load_access_token() (#3584)
* Transparently refresh upstream token in OAuthProxy.load_access_token()

When upstream token validation fails during load_access_token, attempt
to refresh using the stored refresh token before returning None. This
prevents premature 401s that force clients into expensive full re-auth
flows when the upstream token expires.

Co-authored-by: Claude <noreply@anthropic.com>

* Gate transparent refresh on token expiry, add advisory lock

Only attempt upstream refresh when the token is actually expired, not
on any validation failure (scope mismatch, revocation, etc.). Add
per-token advisory lock to prevent concurrent async tasks from racing
to refresh the same upstream token.

* Re-check expiry inside lock, reload from storage after refresh failure

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-22 10:43:44 -04:00
..
oauth_proxy Transparently refresh upstream token in OAuthProxy.load_access_token() (#3584) 2026-03-22 10:43:44 -04:00
providers Extract TokenCache utility, add caching to GitHubTokenVerifier (#3547) 2026-03-18 15:26:09 -04:00
__init__.py Add WorkOS and Azure OAuth providers (#1550) 2025-08-20 16:22:03 -04:00
test_auth_provider.py Upgrade to MCP 1.17+ with RFC 9728 compliance (#2122) 2025-10-17 09:29:23 -04:00
test_authorization.py perf: reduce PBKDF2 iterations in tests, fix warnings and timeouts (#3504) 2026-03-14 16:42:06 -04:00
test_cimd.py Split large test files to comply with loq line limit (#3328) 2026-02-28 11:21:11 -05: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 Use MemoryStore for OAuth proxy tests 2026-02-01 02:30:05 +00:00
test_jwt_issuer.py fix: reject refresh tokens used as Bearer access tokens (#3524) 2026-03-15 15:21:30 -04:00
test_jwt_provider.py fix: resolve ty 0.0.23 type-checking errors and bump pin (#3481) 2026-03-13 19:45:14 -04:00
test_jwt_provider_bearer.py Split large test files to comply with loq line limit (#3328) 2026-02-28 11:21:11 -05:00
test_multi_auth.py Add MultiAuth for composing multiple token verification sources (#3335) 2026-03-02 12:09:22 -05:00
test_oauth_consent_flow.py fix: CSRF double-submit cookie check in consent flow (#3519) 2026-03-15 14:22:01 -04:00
test_oauth_consent_page.py Remove form-action from default consent CSP, forward consent_csp_policy in all providers 2026-03-03 14:55:00 -05:00
test_oauth_mounting.py Use MemoryStore for OAuth proxy tests 2026-02-01 02:30:05 +00:00
test_oauth_proxy_redirect_validation.py Fix CIMD redirect allowlist bypass and cache revalidation (#3098) 2026-02-06 20:08:23 -05:00
test_oauth_proxy_storage.py Drop diskcache dependency (CVE-2025-69872) (#3185) 2026-02-16 16:43:15 -05:00
test_oidc_proxy.py feat: make upstream_client_secret optional in OAuthProxy (#3486) 2026-03-15 11:14:56 -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 Add CIMD (Client ID Metadata Document) support for OAuth (#2871) 2026-02-06 13:44:52 -05:00
test_remote_auth_provider.py Add AzureJWTVerifier for Managed Identity token verification (#3058) 2026-02-02 19:59:13 -05:00
test_ssrf_protection.py Add CIMD (Client ID Metadata Document) support for OAuth (#2871) 2026-02-06 13:44:52 -05:00
test_static_token_verifier.py Add documentation for get_access_token() dependency function (#1446) 2025-08-11 13:01:44 -04:00