Repository navigation
auth: use Bearer challenges for resource metadata - #1396
Merged
guglielmo-san merged 3 commits intoOct 14, 2026
Merged
guglielmo-san merged 3 commits into
guglielmo-san merged 3 commits into
Conversation
Comment on lines
242
to
243
| if u := c.Params["resource_metadata"]; strings.EqualFold(c.Scheme, "Bearer") && u != "" { | ||
| return u |
Contributor
There was a problem hiding this comment.
this represent a behavioral change for existing users that were relying on the basic auth for example.
We should implement a preference for "bearer" with fallback to any other scheme defined
var fallback string
for _, c := range cs {
u := c.Params["resource_metadata"]
if u == "" {
continue
}
if c.Scheme == "bearer" {
return u
}
if fallback == "" {
fallback = u
}
}
return fallback
Restricting the resource_metadata lookup to a Bearer challenge dropped the URL for servers that only challenge with another scheme, such as Basic. Prefer a Bearer challenge and otherwise take the first other scheme that carries one, in both the auth and extauth packages. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
guglielmo-san
approved these changes
Oct 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resourceMetadataURLFromChallengescurrently acceptsresource_metadatafrom any authentication scheme. When aBasicchallenge precedes aBearerchallenge, metadata discovery can select the Basic URL. Restrict both authorization handlers to the Bearer challenge and add regression coverage for each helper.Validation:
go test ./auth ./auth/extauth— passed.main— both test runs failed as expected; both runs on the fix passed.go vet ./...,go build ./..., andgit diff --check— passed.go test ./...has a pre-existing Windows failure inmcp/TestServerConformance/resources.txtar: the fixture expects LF while Windows produces CRLF. The same failure occurs on cleanmain.Fixes #1379