all: stabilize client OAuth support (#861)

Also fix lint errors that were hidden because of the build tag.
This commit is contained in:
Maciej Kisiel 2026-03-31 12:36:31 +02:00 • committed by GitHub
commit 638d404e0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 387 additions and 915 deletions

View file

@ -5,8 +5,6 @@
// Package extauth provides OAuth handler implementations for MCP authorization extensions.
// This package implements Enterprise Managed Authorization as defined in SEP-990.
//go:build mcp_go_client_oauth
package extauth
import (

View file

@ -2,8 +2,6 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
//go:build mcp_go_client_oauth
package extauth
import (

View file

@ -6,8 +6,6 @@
// as part of Enterprise Managed Authorization (SEP-990).
// See https://openid.net/specs/openid-connect-core-1_0.html
//go:build mcp_go_client_oauth
package extauth
import (
@ -121,11 +119,11 @@ func initiateOIDCLogin(
return nil, nil, fmt.Errorf("RedirectURL is required")
}
if len(config.Scopes) == 0 {
return nil, nil, fmt.Errorf("Scopes is required (must include 'openid')")
return nil, nil, fmt.Errorf("at least one scope is required (must include 'openid')")
}
if !slices.Contains(config.Scopes, "openid") {
return nil, nil, fmt.Errorf("Scopes must include 'openid' for OIDC")
return nil, nil, fmt.Errorf("the 'openid' scope is required for OIDC")
}
if err := checkURLScheme(config.IssuerURL); err != nil {

View file

@ -2,8 +2,6 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
//go:build mcp_go_client_oauth
package extauth
import (
@ -161,7 +159,7 @@ func TestInitiateOIDCLogin(t *testing.T) {
c.Credentials = &oauthex.ClientCredentials{ClientID: "test"}
c.RedirectURL = "http://localhost:8080/callback"
},
expectErr: "Scopes is required",
expectErr: "at least one scope is required",
},
}
for _, tt := range tests {