feat(32.1-01): publish one MCP scope list and call context

- pact gains MemberTokenScopeCatalog, MCPAdvertisedScopes and MCPCall
- an empty MCP ScopesSupported resolves to the five fixed names including backend
- pier copies advertised scopes and sets MCPCall beside WithDispatch
This commit is contained in:
2026-10-28 14:32:31 +01:00
parent 2cea3127cc
commit 63d05e8acb
11 changed files with 322 additions and 27 deletions

View File

@@ -18,22 +18,17 @@ import (
"strings"
)
// authorizeAllowedScopes mirrors PHP OAuthAuthorizeController::ALLOWED_SCOPES:
// the allow-list of a server whose Options.ScopesSupported is empty.
var authorizeAllowedScopes = map[string]bool{
"read": true, "write": true, "ai": true, "offline_access": true,
}
// allowedAuthorizeScopes is the set parseAuthorizeScopes accepts on this
// server: exactly Options.ScopesSupported, the values the metadata document
// advertises, so a host that lists an extra scope (such as backend for the
// MCP module) accepts it at authorize; an empty list keeps the PHP default.
// server: the same resolvedScopes slice Metadata advertises. A non-empty
// Options.ScopesSupported is used as given, so a host that lists an extra
// scope accepts it and a list without backend still refuses it. An empty
// list on the MCP flavour resolves to the five fixed names, backend
// included. Scope resolution runs after the client, redirect and PKCE
// checks in Authorize.
func (s *Server) allowedAuthorizeScopes() map[string]bool {
if s == nil || len(s.opts.ScopesSupported) == 0 {
return authorizeAllowedScopes
}
allowed := make(map[string]bool, len(s.opts.ScopesSupported))
for _, sc := range s.opts.ScopesSupported {
scopes := s.resolvedScopes()
allowed := make(map[string]bool, len(scopes))
for _, sc := range scopes {
if sc = strings.TrimSpace(sc); sc != "" {
allowed[sc] = true
}