5.8 KiB
Phase 19.7 gap-closure inputs
Recorded 2026-10-23 from the user's answer at the code-review gate. The gap-closure plans cover three sources:
- Code review (
19.7-REVIEW.md): fix every critical and warning finding (3 critical, 17 warnings) before v0.5.0. Info findings are fixed where cheap; the rest go todeferred-items.mdwith a reason. - Escalation E-1 (sm-servers-app): organisation logo.
- Escalation E-2 (sm-servers-app): plugin-declared scopes for member (
usr_) API tokens.
sm-user-plugin is a core plugin used by many applications: every change is additive (no removed export, route, column or payload field; no changed response shape).
v0.5.0 is tagged only after the gap closure, a fresh code review of the changes, phase verification, Nyquist validation and UAT are all green (user decision 2026-10-23).
E-1: Organisation logo (sm-user-plugin)
Organisations get a logo file field (an image attachment through lagoon/attach), editable in the backend Organisations form, so an application can upload an organisation's logo and show it on the frontend. The frontend organisation payloads gain the logo (URL or attachment object, following how the plugin already exposes user avatars), as an added field only.
E-2: Plugin-declared scopes for member (usr_) API tokens
Escalated by sm-servers-app (PxPx Servers Inventory). Affects sm-user-plugin v0.1.9+ and pact.HasTokenScopes. Priority: blocking for their Phase 02.1 (agent component reporting).
Problem
Member personal API tokens (usr_) can only carry the fixed scopes read, write and ai. A plugin cannot declare its own scopes for them.
sm-user-plugin/classes/api_tokens.go:AllowedAPITokenScopes = []string{"read", "write", "ai"}.MintAPITokenrefuses anything else.sm-user-plugin/controllers/api_tokens.go,apiTokenScopes:POST /_user/api/v1/tokensanswers 422 "The selected scope is invalid." for any other value.pact.HasTokenScopes(TokenScopes() []pact.TokenScope) exists, but onlycabana/token_scopes.goreads it, for the backendg15_token catalog. The user plugin ignores it.
A plugin that wants a narrow agent token (for sm-servers-app: servers:read and servers:write) has to fall back to the generic write. Every app sharing the token table then gives the same scope a different meaning, and a token's scopes no longer say what it is for.
Use case
Organisation members mint a personal token from the app's Nuxt screen and hand it to a recon agent. The agent calls:
GET /_servers/api/v1/servers?host=&port=with scopeservers:readPUT /_servers/api/v1/servers/{id}/components/reportwith scopeservers:write
The routes are guarded by APITokenGuard plus middleware.Scope("servers:write"). The app also checks the member's live role, so no mint-time role check is asked for.
Ask
- Declaring: the user plugin builds its allowed scope list from the built-in
read,writeandaiplus every active plugin'spact.HasTokenScopes. It reusespact.TokenScope, or a user-plugin twin if the backend and frontend catalogs should stay apart. It validates names the way cabana does (pattern, no duplicates, no clash with the built-ins) and fails boot on a bad one. - Minting:
POST /_user/api/v1/tokensandMintAPITokenaccept the declared scopes. - Checking:
middleware.ScopeandAPIToken.HasScopework with the declared scopes, with no special casing. - Listing:
GET /_user/api/v1/tokensreturns them inscopes, as it does today. - Discovery: an endpoint (for example
GET /_user/api/v1/tokens/scopes, behindjwt.auth) or an exported helper that returns the allowed scopes with name, translated label and description, so a frontend can render them without hard-coding.
Not asked for
- A mint-time hook to refuse a scope based on the user's role.
- Any change to backend
g15_tokens or the cabana catalog. - Any change to
tokens_valid_afterhandling (G8 stays as discussed).
Acceptance
- A plugin that declares
servers:writecan mint ausr_token with that scope throughPOST /tokens, and a route withmiddleware.Scope("servers:write")accepts it. - A token without the scope gets 403 "Missing required scope: servers:write".
- An undeclared scope still answers 422 at mint time.
- Two plugins declaring the same scope name, or a plugin redeclaring
read,writeorai, fails boot. - The discovery answer lists the built-ins and the declared scopes with labels.
Open design point for the planner
pact.HasTokenScopes today feeds the backend g15_ catalog in cabana. If the user plugin also reads it, a scope a plugin declares for member tokens would also appear in the admin token catalog, and the reverse. Decide between reusing the interface (one catalog, both token kinds) and a separate frontend interface. The escalation does not ask for any change to the backend catalog, so a separate interface (or an audience field) is likely the safer choice. Record the choice as a decision.
Planning decisions (user, 2026-10-23)
- Four gap-closure plans:
- 19.7-06, pier hardening (lane A), wave 1
- 19.7-07, framework auth (
auth_time), cabana and admin SPA (lane B), plus the E-2 framework seam, wave 1 - 19.7-08, the plugins (sm-user-plugin with C-CR-01, C-CR-02, C-WR-01, E-1 and E-2; oauthserver with C-CR-01 and C-WR-02; Journal with C-IN-01) and the demo, wave 2
- 19.7-09, unit tests, the extended gate and the security-review corrections, wave 3 (the last plan, by project rule)
- Release order: no tag in plans 06-09. Everything is developed and tested against the local framework (
replace ../summercms.go/ go.work). After the re-review, verification, Nyquist validation and UAT pass: tag framework v0.5.0, then tag sm-user-plugin, sm-oauthserver-plugin and sm-journal-plugin requiring v0.5.0, then bump the applications. sm-servers-app waits for that release for E-2.