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:
@@ -27,7 +27,7 @@ Use cases:
|
||||
|
||||
- RFC 8414 metadata document (`wristband.Server.Metadata`) advertising the authorize, token and registration endpoints under the issuer, the `authorization_code` and `refresh_token` grants, S256 PKCE and the RFC 9207 `iss` response parameter.
|
||||
- RFC 7591 dynamic client registration (`wristband.Server.Register`): JSON only, a bounded request body, redirect URI validation (HTTPS, or loopback HTTP), public (`none`) and confidential (`client_secret_post`, `client_secret_basic`) clients, a cap on unrevoked clients and a sweep of old clients that never got consent, all in one transaction.
|
||||
- Authorization endpoint (`wristband.Server.Authorize`): the client and its exact registered redirect URI are validated before any redirect is sent (an unknown client gets a local plain-text 400, never an open redirect); then S256 PKCE, the client's scope ceiling and the RFC 8707 `resource` value are checked, a pending request is stored and the browser is sent to the application's consent page at `<issuer>/connect?request=<id>`. The accepted scopes are the same resolved list `wristband.Server.Metadata` advertises. A non-empty `wristband.Options.ScopesSupported` is used as given (`read`, `write`, `ai` and `offline_access` from `wristband.DefaultOptions`, which still refuses `backend`; a host that lists an extra scope accepts it). An empty or nil list on the MCP flavour resolves to `read`, `write`, `ai`, `offline_access` and `backend`. The OpenID Connect identity scopes `openid`, `profile` and `email` are dropped from the request before that check (RFC 6749 section 3.3 lets a server grant fewer scopes than requested), so a client that also reads the issuer's OpenID Connect discovery document still connects; a request with nothing else left gets the default `read`, and the three are never advertised. Any other value is `invalid_scope`. OpenID Connect discovery stays `openid`, `profile` and `email` and does not use this list. The OAuth server plugin publishes that list as `pact.MCPAdvertisedScopes`; pier copies `pact.MCPAdvertisedScopes.MCPScopesSupported` when it is non-empty. A route the MCP endpoint runs reads the caller with `pact.MCPCallFrom`.
|
||||
- Authorization endpoint (`wristband.Server.Authorize`): the client and its exact registered redirect URI are validated before any redirect is sent (an unknown client gets a local plain-text 400, never an open redirect); then S256 PKCE, the client's scope ceiling and the RFC 8707 `resource` value are checked, a pending request is stored and the browser is sent to the application's consent page at `<issuer>/connect?request=<id>`, or at `wristband.Options.ConsentPath` on the issuer when that is set (an empty path keeps the PHP bytes). The accepted scopes are the same resolved list `wristband.Server.Metadata` advertises. A non-empty `wristband.Options.ScopesSupported` is used as given (`read`, `write`, `ai` and `offline_access` from `wristband.DefaultOptions`, which still refuses `backend`; a host that lists an extra scope accepts it). An empty or nil list on the MCP flavour resolves to `read`, `write`, `ai`, `offline_access` and `backend`. The OpenID Connect identity scopes `openid`, `profile` and `email` are dropped from the request before that check (RFC 6749 section 3.3 lets a server grant fewer scopes than requested), so a client that also reads the issuer's OpenID Connect discovery document still connects; a request with nothing else left gets the default `read` (or `wristband.Options.DefaultScopes`, filtered to the accepted list, when that leaves anything), and the three are never advertised. Any other value is `invalid_scope`. OpenID Connect discovery stays `openid`, `profile` and `email` and does not use this list. The OAuth server plugin publishes that list as `pact.MCPAdvertisedScopes`; pier copies `pact.MCPAdvertisedScopes.MCPScopesSupported` when it is non-empty. A route the MCP endpoint runs reads the caller with `pact.MCPCallFrom`.
|
||||
- Consent operations for the application's own consent screen: `wristband.Server.PendingRequest` (what to show, including `wristband.PendingRequestView.OfflineAccess`, the pending row's flag; `offline_access` is not a scope on the view), `wristband.Server.IssueCode` (grant, returning the redirect URL with `code`, `iss` and `state`; the signature is unchanged) and `wristband.Server.DenyPending` (returning an `access_denied` redirect). Missing, foreign, used and expired requests all report the same `wristband.ErrPendingNotFound`.
|
||||
- Token endpoint (`wristband.Server.Token`): code exchange with PKCE verification, then an access token minted by the application plus a rotating refresh token. Reusing a spent refresh token revokes its whole lineage and the linked access tokens. Expired codes and refresh tokens are swept on each call.
|
||||
- Connected-app revocation: `wristband.Server.Revoke` kills an access token and the refresh lineage attached to it.
|
||||
@@ -138,7 +138,7 @@ func providerRoutes(r pact.Router, srv *wristband.Server) {
|
||||
| `wristband.Server.IssueCode` | Grants consent and returns the redirect URL carrying the code. |
|
||||
| `wristband.Server.DenyPending` | Refuses consent and returns the `access_denied` redirect URL. |
|
||||
| `wristband.Server.Revoke` | Revokes an access token and its refresh-token lineage. |
|
||||
| `wristband.Options` | Issuer, advertised scopes and auth methods, registration limits, resource indicator and token lifetimes. |
|
||||
| `wristband.Options` | Issuer, advertised scopes and auth methods, registration limits, resource indicator, token lifetimes, the authorize consent path and the default scopes. |
|
||||
| `wristband.DefaultOptions` | Defaults for every option except `wristband.Options.Issuer`. |
|
||||
| `wristband.Backend` | Runs a function inside one transaction with a `wristband.Tx`. |
|
||||
| `wristband.Tx` | Transaction-scoped bundle of the stores and the token issuer. |
|
||||
@@ -204,6 +204,8 @@ wristband reads no config keys or environment variables; the application passes
|
||||
| `wristband.Options.CodeTTL` | 10 minutes |
|
||||
| `wristband.Options.AccessTokenTTL` | 1 hour |
|
||||
| `wristband.Options.RefreshTokenTTL` | 30 days |
|
||||
| `wristband.Options.ConsentPath` | none (empty), which hands authorize off to `/connect` on the issuer, byte for byte as the PHP server; a set path (for example `/admin/connect`) replaces `/connect` on the same issuer |
|
||||
| `wristband.Options.DefaultScopes` | none (empty), which keeps the PHP fallback `read` for a request that names no data scope; a set list is filtered to the accepted scopes and replaces `read` when anything is left |
|
||||
|
||||
Always set `wristband.Options.Issuer` and `wristband.Options.Resource` for your deployment. While `wristband.Options.Resource` is empty, an MCP authorization request that sends `resource` is refused with `invalid_target`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user