fastmcp/tests/server/auth
Jeremiah Lowin b07f9ce9ae
Honor OAuth application_type in DCR (SEP-837) (#4621)
* Honor OAuth application_type in DCR (SEP-837)

* Simplify web redirect check per ruff SIM103

* Enforce application_type over HTTP, at auth time, and tighten native scheme rules

Recover the DCR application_type the SDK RegistrationHandler drops (P1), enforce the stored type on the authorization redirect path (P2), restrict native to loopback http + custom schemes (P2), and document the web/native rules (P2).

* Fix loopback range detection and use a positive scheme allowlist

Classify loopback hosts with ipaddress.is_loopback so all of 127.0.0.0/8 counts (a web client could bypass the non-loopback rule with 127.0.0.2). Replace the NON_REDIRECT_NETWORK_SCHEMES denylist with STANDARD_URI_SCHEMES: native now accepts only https, loopback http, and unregistered private-use schemes per RFC 8252, so smb/smtp/nfs and other unlisted standard schemes no longer pass.

* Vendor the IANA scheme registry and consolidate the loopback classifier

Replace the hand-picked STANDARD_URI_SCHEMES with a vendored snapshot of the IANA URI scheme registry (423 schemes), so registered transports nobody enumerated (coap, coaps, stun, turn, mqtt) fail closed instead of passing as private-use. Delete the stale duplicate _is_loopback_host in oauth_proxy/models.py and reuse the ipaddress-based classifier from redirect_validation, restoring loopback port flexibility across all of 127.0.0.0/8.

* Treat the reserved localhost namespace and absolute host forms as loopback

RFC 6761 6.3 reserves the whole localhost namespace for the local machine, so app.localhost and localhost. are loopback just as much as localhost. Previously a web client could register https://app.localhost/callback and bypass the non-loopback rule, while native clients were wrongly refused legitimate http://app.localhost:3000 dev callbacks. The suffix test is anchored on a leading dot so localhost.evil.com and notlocalhost stay non-loopback.

* Narrow scope: drop native scheme classification, keep the web rule

Registry membership cannot separate app-dispatch schemes from network transports (vscode is registered because it is an app scheme), so classifying a native client's scheme rejected callbacks that real MCP clients need. Remove the vendored registry and the private-use test; native now accepts any scheme outside the unsafe set, with cleartext http still limited to loopback. Also reject web registrations that omit redirect_uris rather than storing an unusable localhost placeholder.
2026-07-26 14:24:50 -04:00
..
oauth_proxy Honor OAuth application_type in DCR (SEP-837) (#4621) 2026-07-26 14:24:50 -04:00
providers Speed up the unit test suite, and fix the task-notification race it surfaced (#4550) 2026-07-19 18:52:04 -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 Emit scope step-up challenges for incremental authorization (SEP-2350) (#4623) 2026-07-26 14:13:26 -04:00
test_cimd.py Stabilize upgraded ty checks (#4526) 2026-07-17 17:46:53 -04:00
test_cimd_validators.py Speed up the unit test suite, and fix the task-notification race it surfaced (#4550) 2026-07-19 18:52:04 -04: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 Speed up the unit test suite, and fix the task-notification race it surfaced (#4550) 2026-07-19 18:52:04 -04:00
test_jwt_issuer.py Make the unit suite fast: in-process HTTP tests, no real sleeps, parallel Windows CI (#4554) 2026-07-20 10:51:14 -04:00
test_jwt_provider.py Speed up the unit test suite, and fix the task-notification race it surfaced (#4550) 2026-07-19 18:52:04 -04:00
test_jwt_provider_bearer.py Speed up the unit test suite, and fix the task-notification race it surfaced (#4550) 2026-07-19 18:52:04 -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 [codex] Add OAuthProxy RFC 9207 issuer responses (#4438) 2026-07-19 09:52:43 -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 Honor OAuth application_type in DCR (SEP-837) (#4621) 2026-07-26 14:24:50 -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 [codex] Add OAuthProxy RFC 9207 issuer responses (#4438) 2026-07-19 09:52:43 -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 Fix #4292: SSRF guard breaks OAuth/JWKS fetches behind a corporate HTTP proxy (#4412) 2026-07-18 21:42:52 -04:00
test_static_token_verifier.py Add subject field to AccessToken initialization (#4267) 2026-07-18 21:15:13 -04:00