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:
2026-10-23 20:51:57 +02:00
parent 0b0cae5b53
commit c37c6ce50f
9 changed files with 112 additions and 43 deletions

View File

@@ -225,13 +225,20 @@ type MCPTokenVerifier interface {
}
// MCPGrant is a verified OAuth access token: the frontend user, the client,
// the token row, the granted scopes and the expiry.
// the token row, the granted scopes, the expiry and, for a grant carrying
// the backend scope, the backend account the user consented to.
type MCPGrant struct {
UserID uint
ClientID string
TokenID uint
Scopes []string
ExpiresAt time.Time
// BackendUserID is the backend account the consent page showed when
// the user granted the backend scope. The MCP endpoint gives the grant
// a backend subject only while the user's current link names this
// account, so a grant never acts as an administrator its consent did
// not show; zero (none recorded) gives no backend subject.
BackendUserID uint
}
// ErrMCPTokenInvalid is what an MCPTokenVerifier answers for a token it does