fix(32.2): WR-06 check the consent provider's redirect against the request's redirect URI

cabana loads the pending request on both decisions and refuses (500) a Decide answer whose scheme, user info, host, path or opaque part differ from the registered redirect URI. The admin SPA also refuses blob:, file:, about: and filesystem: and a destination that does not return to the host the consent card showed. Regenerated the admin OpenAPI document and rebuilt modules/boardwalk/dist.
This commit is contained in:
Jakub Zych
2026-11-21 09:32:54 +01:00
parent 60bc6ee68f
commit 0ade662a04
17 changed files with 212 additions and 49 deletions

View File

@@ -49,7 +49,7 @@ When the server offers more than one admin language (`meta.locales` of `GET .../
The route is standalone, without the navigation shell, and needs a session: an anonymous visitor goes to the login screen with the connect path as its redirect, signs in (with any second step the login asks for) and comes back to the same request. The login screen then says why the administrator is signing in.
The card names the client, the signed-in administrator (with a "Use another account" button that signs out of this browser and goes through login again) and the host the browser returns to, which is always shown in full. Below are the scopes the server offered, in catalog order: every one starts ticked except `*`, which starts ticked only when it is the only scope, and ticking `*` clears and disables the others, as on API token creation. A "Stay connected" box, ticked by default, appears only when the client asked for offline access. Nothing is sent until the administrator clicks Allow or Deny, even for a client allowed before, and neither button has initial focus or a shortcut. The answer's `redirect_uri` is opened with `window.location.assign`, never through the router or the login redirect check, and a `javascript:`, `data:` or `vbscript:` URI is refused as a failed answer. An unknown, expired or used request shows an expired card with a link to the admin; when the administrator holds none of the requested scopes only Deny is offered.
The card names the client, the signed-in administrator (with a "Use another account" button that signs out of this browser and goes through login again) and the host the browser returns to, which is always shown in full. Below are the scopes the server offered, in catalog order: every one starts ticked except `*`, which starts ticked only when it is the only scope, and ticking `*` clears and disables the others, as on API token creation. A "Stay connected" box, ticked by default, appears only when the client asked for offline access. Nothing is sent until the administrator clicks Allow or Deny, even for a client allowed before, and neither button has initial focus or a shortcut. The answer's `redirect_uri` is opened with `window.location.assign`, never through the router or the login redirect check, and a `javascript:`, `data:`, `vbscript:`, `blob:`, `file:`, `about:` or `filesystem:` URI, or one that does not return to the host the card showed, is refused as a failed answer (the server already refuses a redirect that does not go back to the request's redirect URI). An unknown, expired or used request shows an expired card with a link to the admin; when the administrator holds none of the requested scopes only Deny is offered.
## Plugins screen

View File

@@ -118,7 +118,7 @@ The authorization endpoint sends the browser to `<issuer>/connect?request=<id>`,
An OAuth server plugin that signs administrators in instead of frontend users answers its verifier's grants with `pact.MCPGrant.Subject` set to `pact.MCPGrantSubjectBackend`, `UserID` 0 and the administrator in `pact.MCPGrant.BackendUserID`. The MCP endpoint then acts as that administrator only, scope-limited like a `g15_` token with the granted scopes (see [MCP](mcp.md)).
The consent page of such grants is the admin's own: the plugin sets `wristband.Options.ConsentPath` to a page under the admin prefix and publishes a `pact.MCPAdminConsent`. cabana serves `GET` and `POST {admin api}/mcp/consent/{request}` for the signed-in administrator (cookie session only, the POST with `X-Requested-With`) and delegates to that provider: `pact.MCPAdminConsent.MCPAdminConsentShow` describes the pending request as a `pact.MCPAdminConsentRequest`, `pact.MCPAdminConsent.MCPAdminConsentDecide` issues the code or the denial for a `pact.MCPAdminConsentDecision` and answers the redirect URI. cabana owns the scope policy, the same as for `g15_` personal tokens: the scopes are the token-scope catalog (`cabana.TokenScopeNames`, labels through `cabana.TokenScopeLabels`), the screen shows only requested scopes the administrator can grant, and an allow drops anything else before Decide runs (`*` collapses as on token creation). A missing provider or request is 404 `request_not_found` (`pact.ErrMCPConsentNotFound`), and nothing left to grant is 422 `no_grantable_scopes` (`pact.ErrMCPConsentNoScopes`).
The consent page of such grants is the admin's own: the plugin sets `wristband.Options.ConsentPath` to a page under the admin prefix and publishes a `pact.MCPAdminConsent`. cabana serves `GET` and `POST {admin api}/mcp/consent/{request}` for the signed-in administrator (cookie session only, the POST with `X-Requested-With`) and delegates to that provider: `pact.MCPAdminConsent.MCPAdminConsentShow` describes the pending request as a `pact.MCPAdminConsentRequest`, `pact.MCPAdminConsent.MCPAdminConsentDecide` issues the code or the denial for a `pact.MCPAdminConsentDecision` and answers the redirect URI. cabana owns the scope policy, the same as for `g15_` personal tokens: the scopes are the token-scope catalog (`cabana.TokenScopeNames`, labels through `cabana.TokenScopeLabels`), the screen shows only requested scopes the administrator can grant, and an allow drops anything else before Decide runs (`*` collapses as on token creation). cabana also loads the request before a deny, and refuses with 500 a redirect from Decide that does not go back to the request's `pact.MCPAdminConsentRequest.RedirectURI` (same scheme, host and path; only the query and fragment may differ). A missing provider or request is 404 `request_not_found` (`pact.ErrMCPConsentNotFound`), and nothing left to grant is 422 `no_grantable_scopes` (`pact.ErrMCPConsentNoScopes`).
## Clients created outside registration