diff --git a/.planning/phases/32.2-mcp-oauth-with-administrator-subjects/32.2-05-changelog-framework.md b/.planning/phases/32.2-mcp-oauth-with-administrator-subjects/32.2-05-changelog-framework.md new file mode 100644 index 00000000..215f9908 --- /dev/null +++ b/.planning/phases/32.2-mcp-oauth-with-administrator-subjects/32.2-05-changelog-framework.md @@ -0,0 +1,24 @@ +## Highlights + +Administrators can now sign in to an MCP client (such as a custom connector in Claude) over OAuth instead of pasting a personal API token. The admin SPA gains a consent screen. An authorization server plugin can hand the browser off to it, and the resulting grants are capped exactly like `g15_` tokens. + +## Added + +- **Administrator MCP grants.** `pact.MCPAdminConsent` lets a plugin issue MCP grants whose subject is an administrator rather than a frontend user. pier treats these grants like personal API tokens: an agent sees the backend tools the administrator may use, narrowed by the granted scopes. +- **Admin consent screen at `/connect`.** It shows the client, the signed-in administrator and the requested scopes. Allow grants the ticked scopes, and Stay connected also grants offline access. The screen has a login hint and a switch-account path, and if the administrator is not signed in, the login returns to the same request. +- **Consent hand-off.** The new `wristband` `ConsentPath` option sends the browser from the authorization endpoint to a consent page, such as the admin's `/connect`. `wristband.CheckConsentPath` validates the path. +- **Consent API.** cabana serves `GET` and `POST {api}/mcp/consent/{request}`. `TokenScopeNames` and `TokenScopeLabels` expose the token scope catalog. +- **Item rows on My account.** Contributions can list items with per-row actions, served at `POST {api}/account/contribution-items/{name}/{item}/actions/{action}`. +- **`BackendAccessRevokedEvent`.** It fires inside the saving transaction whenever an administrator's access changes: deletion, deactivation, a password change (including `admin:reset-password`), and changes to their role, permissions or superuser flag. Listeners can end that administrator's grants atomically with the change. + +## Changed + +- An authorize request that names only `offline_access` now gets the server's `DefaultScopes`, when they are configured. +- A request that names no scope is refused with `invalid_scope` if the server does not accept `read` and sets no `DefaultScopes`. + +## Fixed + +- `admin:reset-password` now runs in a transaction, so after-commit listeners (cache purges, revocations) fire for it. +- The admin consent API refuses a provider redirect that does not match the request's registered redirect URI. The consent screen also refuses `blob:`, `file:`, `about:` and `filesystem:` destinations. +- pier refuses an MCP grant with an unknown subject instead of treating it as a frontend user's grant. +- A `ConsentPath` that is not a same-origin path is refused instead of sending the browser off-site. diff --git a/.planning/phases/32.2-mcp-oauth-with-administrator-subjects/32.2-05-changelog-plugin.md b/.planning/phases/32.2-mcp-oauth-with-administrator-subjects/32.2-05-changelog-plugin.md new file mode 100644 index 00000000..f1e881e1 --- /dev/null +++ b/.planning/phases/32.2-mcp-oauth-with-administrator-subjects/32.2-05-changelog-plugin.md @@ -0,0 +1,23 @@ +## Highlights + +sm-oauthserver-plugin can now be the MCP authorization server for administrators. Set `mcp.subject: backend` and an editor adds the site's `/mcp` as a connector, signs in once with their `/gfadmin` account, and the agent gets the backend tools that account may use. The mode is off by default; applications on the frontend-user flow are unchanged. Requires SummerCMS v0.6.7. + +## Added + +- **Backend-subject mode** (`mcp.subject: backend`). The authorize endpoint hands off to the admin consent screen (`mcp.consent_path`, which defaults to `/connect`). Grants are capped like `g15_` personal tokens. +- **Optional OpenID Connect provider.** `oidc.enabled: false` turns off discovery, JWKS and the OpenID Connect endpoints, for sites that only need MCP sign-in. +- **MCP connections.** Each administrator sees and revokes their own agents on My account. A superuser, or a holder of `golem15.oauthserver.manage_mcp_connections`, sees and revokes everyone's under OAuth clients › MCP connections. +- **Automatic revocation.** An administrator's agents end at once when that administrator is deleted, deactivated or has their password changed, or when their role, permissions or superuser flag change. Refresh tokens rotate. + +## Changed + +- With MCP enabled, an invalid `mcp.consent_path` now fails boot instead of failing each authorize request. +- In backend mode, a loopback `mcp.resource` behind a public issuer fails boot; in user mode it logs a warning. Set the resource to `/mcp` in production. +- Administrators' grants are honoured only in backend mode. + +## Fixed + +- A refresh no longer holds one database connection while waiting for another. +- A temporary database error during a refresh now returns a retryable error instead of ending the connection. +- The consent decision and the code exchange re-check the administrator, so a consent racing a password change or deactivation yields no tokens. +- A pending request's code is issued only once, even when two administrators decide it at the same time. diff --git a/.planning/phases/32.2-mcp-oauth-with-administrator-subjects/32.2-05-changelog-published.txt b/.planning/phases/32.2-mcp-oauth-with-administrator-subjects/32.2-05-changelog-published.txt new file mode 100644 index 00000000..a243d52a --- /dev/null +++ b/.planning/phases/32.2-mcp-oauth-with-administrator-subjects/32.2-05-changelog-published.txt @@ -0,0 +1,2 @@ +https://summercms.io/changelog/summercms-0-6-7 +https://summercms.io/changelog/sm-oauthserver-plugin-0-1-8 diff --git a/.planning/phases/32.2-mcp-oauth-with-administrator-subjects/32.2-UAT.md b/.planning/phases/32.2-mcp-oauth-with-administrator-subjects/32.2-UAT.md index 9bb3cb84..a66fa2e3 100644 --- a/.planning/phases/32.2-mcp-oauth-with-administrator-subjects/32.2-UAT.md +++ b/.planning/phases/32.2-mcp-oauth-with-administrator-subjects/32.2-UAT.md @@ -3,42 +3,44 @@ status: testing phase: 32.2-mcp-oauth-with-administrator-subjects source: [32.2-VERIFICATION.md] started: 2026-11-21T01:52:38.959Z -updated: 2026-11-21T12:27:35.000Z +updated: 2026-11-21T14:26:30.000Z --- ## Current Test number: 1 -name: SC-5 release go-ahead. 32.2-05-release-decision.txt records hold (framework-base v0.6.6, plugin-base v0.1.7). Decide whether to run plan 05 task 5's tag-and-publish branch: framework next free v0.6 patch (v0.6.7 if still free, must contain b1b96d85), sm-oauthserver-plugin v0.1.8 requiring that tag, push the plugin, then the grzyby pointer bump as its own commit (gitlink, go.mod require, regenerated plugins.gen.go), then the two changelog posts the same day. +name: Live connector check (cross-site SameSite=Strict admin cookie, D-03 / RESEARCH A2). After the production deploy, add https://grzybyfunkcjonalne.pl/mcp as a connector in Claude while signed in to /gfadmin, start the OAuth sign-in, then call a Journal tool and revoke the connection on My account. Procedure: ../sm-grzybyfunkcjonalne-app/DEPLOY.md, section 'Live connector check (deferred)'; 32.2-VALIDATION.md, Manual-Only Verifications row 1. expected: | - Tags v0.6.x (must contain the review fixes up to 0ade662a, since plugin d581799 calls wristband.CheckConsentPath) and v0.1.8 on origin, plugin go.mod on the framework tag, app gitlink and go.mod on v0.1.8 with check-deploy.sh passing again, two changelog URLs recorded in 32.2-05-changelog-published.txt; task 5's automated verify passes on the tag-and-publish branch. + After the cross-site redirect from Claude, the /gfadmin/connect consent card shows the signed-in administrator, not the login screen. If it shows login, signing in must return to the same consent request. awaiting: user response ## Tests -### 1. SC-5 release go-ahead. 32.2-05-release-decision.txt records hold (framework-base v0.6.6, plugin-base v0.1.7). Decide whether to run plan 05 task 5's tag-and-publish branch: framework next free v0.6 patch (v0.6.7 if still free, must contain b1b96d85), sm-oauthserver-plugin v0.1.8 requiring that tag, push the plugin, then the grzyby pointer bump as its own commit (gitlink, go.mod require, regenerated plugins.gen.go), then the two changelog posts the same day. -expected: Tags v0.6.x (must contain the review fixes up to 0ade662a, since plugin d581799 calls wristband.CheckConsentPath) and v0.1.8 on origin, plugin go.mod on the framework tag, app gitlink and go.mod on v0.1.8 with check-deploy.sh passing again, two changelog URLs recorded in 32.2-05-changelog-published.txt; task 5's automated verify passes on the tag-and-publish branch. -result: [pending] - -### 2. Live connector check (cross-site SameSite=Strict admin cookie, D-03 / RESEARCH A2). After the production deploy, add https://grzybyfunkcjonalne.pl/mcp as a connector in Claude while signed in to /gfadmin, start the OAuth sign-in, then call a Journal tool and revoke the connection on My account. Procedure: ../sm-grzybyfunkcjonalne-app/DEPLOY.md, section 'Live connector check (deferred)'; 32.2-VALIDATION.md, Manual-Only Verifications row 1. +### 1. Live connector check (cross-site SameSite=Strict admin cookie, D-03 / RESEARCH A2). After the production deploy, add https://grzybyfunkcjonalne.pl/mcp as a connector in Claude while signed in to /gfadmin, start the OAuth sign-in, then call a Journal tool and revoke the connection on My account. Procedure: ../sm-grzybyfunkcjonalne-app/DEPLOY.md, section 'Live connector check (deferred)'; 32.2-VALIDATION.md, Manual-Only Verifications row 1. expected: After the cross-site redirect from Claude, the /gfadmin/connect consent card shows the signed-in administrator, not the login screen. If it shows login, signing in must return to the same consent request. result: [pending] -### 3. Live connector scope behaviour (32.2-VALIDATION.md, Manual-Only Verifications row 2). In the same live run, note which scope value Claude sends to /oauth/mcp/authorize and whether the consent card offers the expected scopes. +### 2. Live connector scope behaviour (32.2-VALIDATION.md, Manual-Only Verifications row 2). In the same live run, note which scope value Claude sends to /oauth/mcp/authorize and whether the consent card offers the expected scopes. expected: The consent card lists the scopes the administrator can grant (journal, journal:read and so on) with Stay connected. If Claude asks only for offline_access, the backend-mode DefaultScopes (token catalog) are now applied (FW-WR-01 fixed in fa7a8482), so a 'no grantable scope' card with only Deny is a regression. result: [pending] -### 4. Production resource override (review PA-WR-09). During the deploy, check that SUMMER_GOLEM15__OAUTHSERVER__MCP__RESOURCE is set in go/.env and that GET /.well-known/oauth-protected-resource/mcp .resource equals the authorization server's resource (https://grzybyfunkcjonalne.pl/mcp). +### 3. Production resource override (review PA-WR-09). During the deploy, check that SUMMER_GOLEM15__OAUTHSERVER__MCP__RESOURCE is set in go/.env and that GET /.well-known/oauth-protected-resource/mcp .resource equals the authorization server's resource (https://grzybyfunkcjonalne.pl/mcp). expected: Both resources are the public https URL; the committed loopback default (http://127.0.0.1:8096/mcp) is not served. `scripts/check-deploy.sh --live` passes on the server; a missing override now fails boot in backend mode (PA-WR-09). -result: [pending] +result: pass +source: automated +evidence: 2026-11-21 deploy of e60eb13 to alexandria; go/.env sets the override, `scripts/check-deploy.sh --live` ok, /.well-known/oauth-protected-resource/mcp resource https://grzybyfunkcjonalne.pl/mcp with authorization server https://grzybyfunkcjonalne.pl ## Summary -total: 4 -passed: 0 +total: 3 +passed: 1 issues: 0 -pending: 4 +pending: 2 skipped: 0 blocked: 0 ## Gaps + +## Decisions + +- SC-5 release (not a UAT row): tag-and-publish approved 2026-11-21. summercms v0.6.7, sm-oauthserver-plugin v0.1.8, grzyby pointer bump e60eb13, deployed to alexandria; posts in 32.2-05-changelog-published.txt.