feat(32.2-01): administrator-only MCP grants and a configurable consent handoff
- pact: MCPGrant.Subject with MCPGrantSubjectBackend, MCPSubject.ScopeLimited - pier: a backend-subject grant resolves straight to a scope-limited backend subject bound to oauth:backend:<client>:<admin>, no link lookup, no ceiling - pier: the backend guard scope-limits ScopeLimited subjects like g15_ tokens - wristband: Options.ConsentPath and Options.DefaultScopes; defaults unchanged - smoke tests TestBackendSubjectSmoke (Postgres) and TestConsentPathSmoke
This commit is contained in:
@@ -99,15 +99,17 @@ func (g backendGuard) MCPDispatch(ctx context.Context, subject pact.MCPSubject,
|
||||
|
||||
// principal loads the admin through cabana.BackendPrincipal (nil when the
|
||||
// admin does not exist or is deactivated) and, for a personal-token subject
|
||||
// (no OAuth client), sets the scope limit for method; a token whose stored
|
||||
// scopes are all unknown answers errScopeUnavailable, as the HTTP guard
|
||||
// refuses it.
|
||||
// (no OAuth client) or a ScopeLimited subject (an administrator-only OAuth
|
||||
// grant), sets the scope limit for method; scopes that are all unknown
|
||||
// answer errScopeUnavailable, as the HTTP guard refuses such a token. A
|
||||
// linked user-mode grant (ClientID set, ScopeLimited false) stays
|
||||
// unlimited.
|
||||
func (g backendGuard) principal(ctx context.Context, subject pact.MCPSubject, method string) (*bouncer.Principal, error) {
|
||||
principal, err := cabana.BackendPrincipal(ctx, g.app, subject.UserID)
|
||||
if err != nil || principal == nil {
|
||||
return nil, err
|
||||
}
|
||||
if subject.ClientID == "" && subject.TokenID != 0 {
|
||||
if (subject.ClientID == "" && subject.TokenID != 0) || subject.ScopeLimited {
|
||||
limit, known, _ := cabana.ScopeLimitFor(g.app, subject.Scopes, method)
|
||||
if known == 0 {
|
||||
return nil, errScopeUnavailable
|
||||
|
||||
Reference in New Issue
Block a user