fix(19.7): RC-WR-01 a backend grant acts only as the administrator it was consented for
pact.MCPGrant gains BackendUserID, the backend account the consent page showed. pier gives an OAuth identity a backend subject (on resolution and after a link event) only while the user's link names that account; a link to anyone else, or no recorded account, gives none, so a link changed after the consent never re-targets the grant.
This commit is contained in:
@@ -534,9 +534,26 @@ func (g methodGuard) MCPAllowsMethod(_ context.Context, subject pact.MCPSubject,
|
||||
return g.decide(subject, req, perms, method), nil
|
||||
}
|
||||
|
||||
// grant builds one verifier answer valid for an hour.
|
||||
// consentedAdmin is the backend account every backend grant of grant was
|
||||
// consented for; the tests that link a user link it to this administrator.
|
||||
const consentedAdmin = 42
|
||||
|
||||
// grant builds one verifier answer valid for an hour. A grant carrying the
|
||||
// backend scope was consented for consentedAdmin.
|
||||
func grant(user uint, client string, token uint, scopes ...string) pact.MCPGrant {
|
||||
return pact.MCPGrant{UserID: user, ClientID: client, TokenID: token, Scopes: scopes, ExpiresAt: time.Now().Add(time.Hour)}
|
||||
g := pact.MCPGrant{UserID: user, ClientID: client, TokenID: token, Scopes: scopes, ExpiresAt: time.Now().Add(time.Hour)}
|
||||
if slices.Contains(scopes, "backend") {
|
||||
g.BackendUserID = consentedAdmin
|
||||
}
|
||||
return g
|
||||
}
|
||||
|
||||
// boundGrant is grant consented for the backend account admin (zero: none
|
||||
// recorded).
|
||||
func boundGrant(user uint, client string, token, admin uint, scopes ...string) pact.MCPGrant {
|
||||
g := grant(user, client, token, scopes...)
|
||||
g.BackendUserID = admin
|
||||
return g
|
||||
}
|
||||
|
||||
// fakeVerifier answers the grants it holds; revoke drops one. Its default
|
||||
|
||||
Reference in New Issue
Block a user