Resolve dot-segments when deriving and matching OAuth resource URLs - #3343
Resolve dot-segments when deriving and matching OAuth resource URLs#3343maxisbey wants to merge 1 commit into
Code review found 2 potential issues
Found 6 candidates, confirmed 2. See review comments for details.
Details
| Severity | Count |
|---|---|
| 🔴 Important | 0 |
| 🟡 Nit | 0 |
| 🟣 Pre-existing | 2 |
| Severity | File:Line | Issue |
|---|---|---|
| 🟣 Pre-existing | src/mcp/shared/auth_utils.py:55 |
Pre-existing, left behind by this partial fix: the resource URL is now derived with dot-segments floored at the path roo |
| 🟣 Pre-existing | src/mcp/shared/auth_utils.py:84 |
Pre-existing: default-port normalization asymmetry — the PRM 'resource' side is WHATWG-normalized by pydantic (explici |
Annotations
Check notice on line 55 in src/mcp/shared/auth_utils.py
claude / Claude Code Review
Pre-existing, left behind by this partial fix: the resource URL is now derived with dot-segments floored at the path root, but build_protected_resource_metadata_discovery_urls (src/mcp/client/auth/utils.py:90) still embeds the raw unresolved path into '/.
Pre-existing, left behind by this partial fix: the resource URL is now derived with dot-segments floored at the path root, but build_protected_resource_metadata_discovery_urls (src/mcp/client/auth/utils.py:90) still embeds the raw unresolved path into '/.well-known/oauth-protected-resource{path}' via urljoin, whose RFC 3986 resolution has no floor at the well-known prefix — a '..' that the new _remove_dot_segments correctly discards at root instead consumes the 'oauth-protected-resource' segme
Check notice on line 84 in src/mcp/shared/auth_utils.py
claude / Claude Code Review
Pre-existing: default-port normalization asymmetry — the PRM `resource` side is WHATWG-normalized by pydantic (explicit `:443`/`:80` is stripped, e.g. `AnyHttpUrl("https://host:443/mcp")` serializes as `https://host/mcp`), but `resource_url_from_server_
Pre-existing: default-port normalization asymmetry — the PRM `resource` side is WHATWG-normalized by pydantic (explicit `:443`/`:80` is stripped, e.g. `AnyHttpUrl("https://host:443/mcp")` serializes as `https://host/mcp`), but `resource_url_from_server_url()` (netloc kept verbatim at src/mcp/shared/auth_utils.py:54) and the netloc equality check in `check_resource_allowed()` (line 84) keep the explicit default port from the raw `server_url` string. The PR's stated goal is making both operands