Skip to content

fix: add RFC 8707 resource validation to OAuth client#2069

Merged
felixweinberger merged 1 commit intov1.xfrom
fweinberger/v1x-rfc8707-resource-validation
Feb 17, 2026
Merged

fix: add RFC 8707 resource validation to OAuth client#2069
felixweinberger merged 1 commit intov1.xfrom
fweinberger/v1x-rfc8707-resource-validation

Conversation

@felixweinberger
Copy link
Contributor

@felixweinberger felixweinberger commented Feb 16, 2026

Stacked on #2068.
Partial backport of #2010.

Motivation and Context

The conformance test auth/resource-mismatch requires the client to validate that the Protected Resource Metadata (PRM) resource field matches the server URL before proceeding with authorization (RFC 8707). This was implemented on main in PR #2010 but missing from v1.x.

How Has This Been Tested?

  • 3 unit tests added (reject mismatch, accept match, trailing slash normalization)
  • Full conformance suite: 251/251 passing (server 40/40, client 211/211)
  • Baseline check passes with empty expected-failures

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Backport of main PR #2010. The validation method rejects PRM resources that don't match the server URL, with trailing slash normalization to handle root URL variations.

@felixweinberger felixweinberger marked this pull request as draft February 16, 2026 17:57
@felixweinberger felixweinberger force-pushed the fweinberger/v1x-rfc8707-resource-validation branch from 21be170 to 2b24ca3 Compare February 16, 2026 17:59
discovery_response = httpx.Response(
200,
content=b'{"resource": "https://api.example.com/mcp", "authorization_servers": ["https://auth.example.com"]}',
content=b'{"resource": "https://api.example.com/v1/mcp", "authorization_servers": ["https://auth.example.com"]}',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the new validation caught that the mock PRM resource didn't match the fixture's server URL

@felixweinberger felixweinberger force-pushed the fweinberger/v1x-rfc8707-resource-validation branch 2 times, most recently from 65d0957 to b899f8e Compare February 16, 2026 18:12
@felixweinberger felixweinberger marked this pull request as ready for review February 16, 2026 18:14
Base automatically changed from fweinberger/v1x-conformance-ci to v1.x February 16, 2026 19:27
@felixweinberger felixweinberger force-pushed the fweinberger/v1x-rfc8707-resource-validation branch from b899f8e to 005bcbc Compare February 17, 2026 14:24
Backport from main (PR #2010). The client now validates that the
Protected Resource Metadata resource field matches the server URL
before proceeding with authorization, rejecting mismatched resources
per RFC 8707.

This fixes the auth/resource-mismatch conformance test, bringing
client conformance to 251/251 (100%) on v1.x.
@felixweinberger felixweinberger force-pushed the fweinberger/v1x-rfc8707-resource-validation branch from 005bcbc to 3cb4e7c Compare February 17, 2026 14:26
@felixweinberger felixweinberger merged commit 6745894 into v1.x Feb 17, 2026
39 of 40 checks passed
@felixweinberger felixweinberger deleted the fweinberger/v1x-rfc8707-resource-validation branch February 17, 2026 14:35
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