diff --git a/.planning/ROADMAP.md b/.planning/ROADMAP.md index 5f72b789..06a80678 100644 --- a/.planning/ROADMAP.md +++ b/.planning/ROADMAP.md @@ -1918,7 +1918,7 @@ Phases execute in numeric order: 1 → 2 → 3 → 4 → 5 → 6 → 7 → 8 → | 33. SEO output, audit and content | 16/16 | In Progress| | | 34. Plugin marketplace | 6/6 | In Progress| | | 35. Mail templates and layouts editor | 9/9 | Complete | 2026-11-14 | -| 36. Granular MCP OAuth & API token scope picker | 0/4 | Planned | - | +| 36. Granular MCP OAuth & API token scope picker | 4/4 | Complete | 2026-11-24 | ## Backlog @@ -2017,13 +2017,13 @@ Plans: Plans: **Wave 1** -- [ ] 36-01-PLAN.md — Go backend scope metadata (`pact.TokenScope.Group`, `cabana.AdminAPITokenScope` `plugin_id`/`group` + D-16 fallback), `cabana.TokenScopeCovers` + `pier.Mount` boot warning, EN/PL phrasebooks, OpenAPI/TS regen, READMEs & docs +- [x] 36-01-PLAN.md — Go backend scope metadata (`pact.TokenScope.Group`, `cabana.AdminAPITokenScope` `plugin_id`/`group` + D-16 fallback), `cabana.TokenScopeCovers` + `pier.Mount` boot warning, EN/PL phrasebooks, OpenAPI/TS regen, READMEs & docs **Wave 2** *(blocked on Wave 1 completion)* -- [ ] 36-02-PLAN.md — Shared 3-tier access selector & `ScopePicker` on `ConnectView.vue` (light-literal modal) and `ApiTokenCreateDialog.vue` (fixed-width in-dialog swap), rebuilt `modules/boardwalk/dist` +- [x] 36-02-PLAN.md — Shared 3-tier access selector & `ScopePicker` on `ConnectView.vue` (light-literal modal) and `ApiTokenCreateDialog.vue` (fixed-width in-dialog swap), rebuilt `modules/boardwalk/dist` **Wave 3** *(blocked on Wave 2 completion)* -- [ ] 36-03-PLAN.md — Core plugin `pact.HasTokenScopes` rollout in `sm-sitemap-plugin` (`sitemap`/`sitemap:read`) and `sm-seo-plugin` (`seo`/`seo:read`) with EN/PL copy, READMEs, and tests +- [x] 36-03-PLAN.md — Core plugin `pact.HasTokenScopes` rollout in `sm-sitemap-plugin` (`sitemap`/`sitemap:read`) and `sm-seo-plugin` (`seo`/`seo:read`) with EN/PL copy, READMEs, and tests **Wave 4** *(blocked on Wave 3 completion)* -- [ ] 36-04-PLAN.md — Comprehensive Go & Vitest unit/component suites (closing all 7 UI-SPEC backstops), full release gates, human release-tag checkpoint, and `sm-grzybyfunkcjonalne-app` local E2E proof +- [x] 36-04-PLAN.md — Comprehensive Go & Vitest unit/component suites (closing all 7 UI-SPEC backstops), full release gates, human release-tag checkpoint, and `sm-grzybyfunkcjonalne-app` local E2E proof diff --git a/.planning/STATE.md b/.planning/STATE.md index 6eae7e06..b23714d7 100644 --- a/.planning/STATE.md +++ b/.planning/STATE.md @@ -3,17 +3,17 @@ gsd_state_version: "1.0" milestone: v1.0 current_phase: 36 current_phase_name: granular-mcp-oauth-api-token-scope-picker -status: executing -stopped_at: Phase 36 context gathered -last_updated: "2026-11-24T17:54:17.146Z" -last_activity: 2026-11-21 -last_activity_desc: Phase 32.2 complete, transitioned to Phase 19.3 -state_head: 4c078005c0ef71c191dde752c5082981bb843f64 +status: complete +stopped_at: Phase 36 complete +last_updated: "2026-11-24T21:15:00.000Z" +last_activity: 2026-11-24 +last_activity_desc: Phase 36 complete (v0.6.8, sm-sitemap-plugin v0.2.1, sm-seo-plugin v0.2.1) +state_head: a219d4d8 progress: total_phases: 54 - completed_phases: 38 + completed_phases: 39 total_plans: 313 - completed_plans: 298 + completed_plans: 302 msd_state_version: "1.0" milestone_name: milestone --- @@ -29,10 +29,10 @@ See: .planning/PROJECT.md (updated 2026-11-21) ## Current Position -Phase: 36 (granular-mcp-oauth-api-token-scope-picker) — READY TO EXECUTE -Plan: Not started -Status: Ready to execute -Last activity: 2026-11-21 — Phase 32.2 complete, transitioned to Phase 19.3 +Phase: 36 (granular-mcp-oauth-api-token-scope-picker) — COMPLETE +Plan: 4/4 complete +Status: Complete +Last activity: 2026-11-24 — Phase 36 complete (v0.6.8, sm-sitemap-plugin v0.2.1, sm-seo-plugin v0.2.1) Progress: [████████░░] 77% @@ -70,6 +70,7 @@ Progress: [████████░░] 77% | 19.6.1 | 5 | - | - | | 35 | 9 | - | - | | 32.2 | 5 | - | - | +| 36 | 4 | - | - | **Recent Trend:** diff --git a/.planning/phases/36-granular-mcp-oauth-api-token-scope-picker/36-REVIEW-DISPOSITION.md b/.planning/phases/36-granular-mcp-oauth-api-token-scope-picker/36-REVIEW-DISPOSITION.md new file mode 100644 index 00000000..f380b96c --- /dev/null +++ b/.planning/phases/36-granular-mcp-oauth-api-token-scope-picker/36-REVIEW-DISPOSITION.md @@ -0,0 +1,36 @@ +--- +phase: 36 +review: 36-REVIEW.md +titles: json +findings: + - id: WR-01 + severity: warning + disposition: open + title: "Missing request sequence guard in `ApiTokenCreateDialog.vue` `loadScopes()`" + - id: IN-01 + severity: info + disposition: open + title: "`warnUncoveredBackendWriteTools` recompiles the plugin token scope catalog once per backend write tool when `cabana` is not activated on `app`" + - id: IN-02 + severity: info + disposition: open + title: "Accordion header toggle buttons appear interactive during search even though clicking is a no-op" + - id: IN-03 + severity: info + disposition: open + title: "Static DOM `panelId` and mount-only `expanded` initialization in `ScopePicker.vue`" +open: 4 +total: 4 +recorded: "2026-11-24" +--- + +# Phase 36: Code Review Disposition + +| Finding | Severity | Disposition | Source | +|---------|----------|-------------|--------| +| WR-01 | warning | open | - | +| IN-01 | info | open | - | +| IN-02 | info | open | - | +| IN-03 | info | open | - | + +Dispositions: `open` (recorded, not yet triaged), `fixed`, `skipped`, `deferred`. diff --git a/.planning/phases/36-granular-mcp-oauth-api-token-scope-picker/36-REVIEW.md b/.planning/phases/36-granular-mcp-oauth-api-token-scope-picker/36-REVIEW.md new file mode 100644 index 00000000..b09b402f --- /dev/null +++ b/.planning/phases/36-granular-mcp-oauth-api-token-scope-picker/36-REVIEW.md @@ -0,0 +1,99 @@ +--- +phase: 36 +status: reviewed +depth: standard +findings: + critical: 0 + warning: 1 + info: 3 +reviewed_at: "2026-11-24" +--- + +# Phase 36: Code Review Report + +**Phase:** `36-granular-mcp-oauth-api-token-scope-picker` +**Reviewed:** 2026-11-24 +**Depth:** standard +**Scope:** Framework diff `7644786d..2661e0f3` (`modules/pact`, `modules/cabana`, `modules/pier`, `modules/phrasebook`, `admin/src/`, `docs/`), sibling plugin scope declarations (`../sm-sitemap-plugin/token_scopes.go`, `../sm-seo-plugin/token_scopes.go` + EN/PL phrasebooks and tests), and `../sm-grzybyfunkcjonalne-app/scripts/smoke-mcp-oauth.sh`. +**Status:** reviewed (`0` critical, `1` warning, `3` info) + +## Summary + +Phase 36 is clean on security, privilege boundaries, XSS safety, and contract compliance. All ten STRIDE threats (`T-36-01`..`T-36-10`) and every plan prohibition from `36-01-PLAN.md`..`36-04-PLAN.md` hold up under code inspection: + +- **Backend scope metadata & validation (`T-36-01`, `T-36-03`):** `pact.TokenScope.Group` is additive while `pact.ValidTokenScopeName` / `tokenScopeNameRE` remain untouched (D-01, D-05, D-14). `validateTokenScopeMessageKeys` fails boot on missing `::` phrase keys in `Group`. `cabana.AdminAPITokenScope` emits always-present `plugin_id` and `group` strings (no `omitempty`), strictly empty for `*`, `admin:read`, and unknown stored scopes; `resolveScopeGroup` follows the exact D-16 fallback order with deterministic `reg.permissionOrder` iteration. +- **Boot-time uncovered write MCP tool warning (`T-36-02`):** `cabana.TokenScopeCovers` excludes `*`, delegates to `scopeCoversAll` (returning `false` for empty `permissions` on write methods, matching runtime `allowsUnderScope`), and `pier.Mount` emits one sorted structured `Warn` per plugin without failing boot (D-18). +- **Admin SPA scope picker & `admin:read` PII footgun fix (`T-36-04`, `T-36-05`, `T-36-06`):** Both `ConnectView.vue` and `ApiTokenCreateDialog.vue` default to `Read-only (admin:read)` when grantable (D-03, D-08). Custom mode defaults `adminRead` to `false` and `computeSubmittedScopes` omits `admin:read` unless explicitly opted in; toggling ON locks `read_only` rows with a `Lock` icon + `via admin:read` badge, disables per-group `Read`, makes `Clear` selective on unlocked scopes, and restores prior `:read` ticks if toggled back OFF (D-04, D-17). Zero `v-html` exists across the new and modified Vue files. All Phase 32.2 `ConnectView` invariants (`safeDestination`, `FORBIDDEN_PROTOCOLS`, `window.location.assign`, no auto-allow, no auto-focus/hotkeys on Allow/Deny) are preserved. `.connect-light-surface` is defined in `admin/src/styles/main.css` `@layer components` pinning both `--c-*` and `--color-*` aliases on card and portaled modal (D-12). `ApiTokenCreateDialog.vue` keeps a single `DialogOverlay` at fixed `max-w-[560px]`, unmounts the `mod+s mod+enter` submit button in picker view, and intercepts `Escape` to discard the draft without closing the dialog or losing `name`/`expires` (D-13). `ApiTokensPanel.vue` is untouched. +- **Sibling plugins & E2E smoke script (`T-36-07`, `T-36-08`, `T-36-09`, `T-36-10`):** `sm-sitemap-plugin/token_scopes.go` and `sm-seo-plugin/token_scopes.go` strictly scope permissions to `golem15.sitemap.*` and `golem15.seo.*`, restrict `:read` scopes to `GET`/`HEAD`, define all EN/PL phrase keys, and cover 100% of backend write MCP tools with zero `pier.Mount` warnings. `smoke-mcp-oauth.sh` uses `umask 077`, passes secrets only via env/0600 files (never CLI arguments or logs), verifies grouped scopes and zero boot warnings, and cleans up temp files on `EXIT`. No consuming application name appears in framework code or `docs/`. + +One non-blocking **Warning** (async stale-response race in `ApiTokenCreateDialog.vue`'s `loadScopes()`) and three **Info** items were found. + +## Critical Issues + +None. + +## Warnings + +### WR-01: Missing request sequence guard in `ApiTokenCreateDialog.vue` `loadScopes()` + +**File:** `admin/src/components/account/ApiTokenCreateDialog.vue:141-175` +**Issue:** Unlike `ConnectView.vue` (which guards `load()` with `let loadSeq = 0; const seq = ++loadSeq` at lines 56 and 143), `ApiTokenCreateDialog.vue`'s `loadScopes()` does not track a request sequence number or check `props.open` when `api.GET('/account/tokens/scopes')` settles: + +```ts +async function loadScopes(): Promise { + scopesLoading.value = true + scopesFailed.value = false + scopes.value = [] + resetScopeSelection([]) + try { + const result = await api.GET('/account/tokens/scopes') + if (result.data) { + const list = result.data.data ?? [] + scopes.value = list + resetScopeSelection(list) + scopesFailed.value = list.length === 0 + return + } + scopesFailed.value = true + } catch { + scopesFailed.value = true + } finally { + scopesLoading.value = false + } +} +``` + +If the administrator opens the dialog, closes it while `/account/tokens/scopes` is still in flight, and immediately re-opens it: +1. When request #1 resolves/rejects first, its `finally` clears `scopesLoading.value = false` while request #2 is still running. +2. If request #1 resolves *after* request #2 (e.g., after the user has already switched to `Custom` and opened `ScopePicker`), request #1 calls `resetScopeSelection(list)`, closing the picker and silently resetting the user's tier/draft back to `Read-only (admin:read)`. +3. If the dialog stays closed while request #1 resolves, `scopes.value` and tier state are repopulated in the background after the close watcher already reset them. + +**Fix:** Mirror `ConnectView.vue`'s sequence guard: add `let loadSeq = 0`, capture `const seq = ++loadSeq` at the top of `loadScopes()`, increment `loadSeq++` in the `watch(() => props.open)` close branch, and ignore stale responses (including skipping `scopesLoading.value = false` in `finally`) whenever `seq !== loadSeq || !props.open`. + +## Info + +### IN-01: `warnUncoveredBackendWriteTools` recompiles the plugin token scope catalog once per backend write tool when `cabana` is not activated on `app` + +**File:** `modules/pier/uncovered_scopes_warning.go:22-31`, `modules/cabana/token_scopes_export.go:67-83` +**Issue:** In normal server boot (`surf`), `cabana.Activate` runs before `pier.Mount`, so `publishedResolverGuard(app)` returns the cached `guard.reg.tokenScopes` in O(1). However, when `pier.Mount` is called without an activated `cabana` guard (such as standalone tests or custom hosts), `tokenScopeCatalogFor(app, plugins)` invokes `compileTokenCatalog(plugins)` inside the loop once for every backend write tool in `cat.tools`. In addition, if `compileTokenCatalog(plugins)` returns an error in that fallback path, `tokenScopeCatalogFor` silently returns `nil` and `TokenScopeCovers` returns `false`, causing `pier` to emit `"not covered by any non-* TokenScope"` warnings for every plugin instead of noting a catalog compile error (though `cabana.Activate` still fails boot separately). +**Fix:** Optional optimization: resolve or compile the scope catalog once before iterating `cat.tools` (or expose an internal/batch helper if needed). No change required for standard `surf` boot. + +### IN-02: Accordion header toggle buttons appear interactive during search even though clicking is a no-op + +**File:** `admin/src/components/scopes/ScopePicker.vue:188-199`, `admin/src/components/scopes/ScopePicker.vue:395-418` +**Issue:** Per D-07, all matching groups auto-expand while `isSearching` is `true` without mutating the saved `expanded` set. In `ScopePicker.vue`, `toggleGroup` returns early when `isSearching.value` is `true`, while the `