fix(32.2): WR-02 refuse a ConsentPath that is not a same-origin path

Add wristband.CheckConsentPath (additive, for hosts to call at boot) and make Authorize answer 500 before storing a pending request while the configured path fails it, so the handoff can never leave the issuer's origin.
This commit is contained in:
Jakub Zych
2026-11-21 09:08:12 +01:00
parent fa7a84821e
commit 1dcc2ed06d
5 changed files with 91 additions and 3 deletions

View File

@@ -147,6 +147,7 @@ func providerRoutes(r pact.Router, srv *wristband.Server) {
| `wristband.RefreshTokenStore` | Persists `wristband.RefreshTokenRecord` lineage rows, including rotation and lineage revocation. |
| `wristband.AccessTokenIssuer` | Mints and revokes the application's access tokens, returning a `wristband.IssuedToken`. |
| `wristband.IssueClientCredentials` | Generates a client ID and, for confidential clients, a one-time secret and its hash. |
| `wristband.CheckConsentPath` | Returns why a path cannot be `wristband.Options.ConsentPath` (it must start with a single `/` and carry no `?`, `#`, `\`, `@`, whitespace or control character), or nil; call it at boot. `wristband.Server.Authorize` answers 500 instead of redirecting while the configured path fails it. |
| `wristband.RejectRedirectURI` | Returns why a redirect URI is not acceptable, or an empty string. |
| `wristband.ErrPendingNotFound` | The pending request does not exist for this user or is no longer usable. |
| `wristband.ErrNoGrantableScopes` | `wristband.Server.IssueCode` was called with no scopes. |
@@ -204,7 +205,7 @@ 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.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; it must pass `wristband.CheckConsentPath` |
| `wristband.Options.DefaultScopes` | none (empty), which keeps the PHP fallback `read` for a request that names no data scope (`invalid_scope` when `read` is not accepted); a set list is filtered to the accepted scopes and replaces `read` when anything is left, and then also applies to a request that names only `offline_access` |
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`.