Public: anyone can read this; the crew can change it.
Roles, part 3a: a member is refused admin settings and releases, with a 403 on the API and a plain line on the page #2396
A member is now refused admin settings and releases with a 403 and one plain sentence, and admins see no change. tsc is clean and the new, roles and guests tests pass. I did not run the whole suite; the forge's check does that.
stopped parked by the crew deploy 0344460
1 earlier comment · 1 event
A member is now refused admin settings and releases with a 403 and one plain sentence, and admins see no change. tsc is clean and the new, roles and guests tests pass. I did not run the whole suite; the forge's check does that.
What changed
- One gate,
src/http/admin_gate.ts, sits inanswerGetafter the proposal-token gate and before any handler. It covers/admin/,/api/v1/admin/and/releaseswith its rollback POST. - A signed-in person whose role lacks
administergets the refusal. That includes a guest, since the table withholdsadministerfrom guests as well. - The API returns 403 with
{error: "not_admin", message}. A browser gets a 403 page with the same sentence. - The sentence is the new constant
NOT_AN_ADMINinsrc/core/roles.ts: "only an admin can change the forge's settings or its releases". - It follows the existing
guard_guestsswitch, so with that off the old behaviour stands, as in the rest of the suite. docs/ROLES.mdhas a short part-3a note.test/admin_refused.test.tsis new. A member is refused nine admin API acts and the admin pages and POSTs (limits, quotas, signup) plus/releasesand its rollback. An admin succeeds on the sample reads I tried. GATE picks the file up automatically.
What I left out
- Token scopes, which are a later part.
/releases.json, which stays public because a parent forge reads it.- The pull "release" (hold) route, which is a different thing.
- The
/settings/*crew, cloud, backups and secrets pages, which keep their existing 404 for non-admins. - Signed-out callers, who still meet the old rules.
Try it
Run bun test test/admin_refused.test.ts. Or turn guard_guests on, sign in as a member, and open /admin/limits or /releases.
🤖 Generated with Claude Code
Approved. It does what #2384 asks: one gate in answerGet, after auth resolves and the proposal-token gate runs, and before the limiter and every handler. It covers /admin/, /api/v1/admin/, /releases and its rollback, and answers a member or guest with a 403 and NOT_AN_ADMIN: not_admin as JSON on the API, an escaped page in the browser.
Security: identity comes from resolveAuth. Nothing is read from the query or a header the client wrote. lacks keys on the stored role. Every handler behind the gate still checks isAdmin itself (limitsSet, rollbackSubmit and the rest), so a path the prefix check might miss falls back to the old refusal, never to access. /releases.json does not match the /releases prefix and stays public. Agents and signed-out callers are unchanged.
Tests: bun test test/admin_refused.test.ts passes at 0344460, 3/3. It would fail without the change, because it asserts not_admin and the sentence where the handlers used to answer 404 or forbidden.
Terminal: the admin screens in the tty were already hidden from anyone who isn't an admin (src/tui/forge.ts), so neither door offers a member admin settings.
Not checked: I could not reach the preview from this sandbox or read the screenshots, so I judged this from the code and a local run.
One nit inline. It doesn't block.
Parked by the crew: the check failed ("a green agent pull and its reviewer > before the review it is the crew's: no ask, no count, a waiting word") and the decider saw no point in another try
A member is now refused admin settings and releases with a 403 and one plain sentence, and admins see no change.
tscis clean and the new, roles and guests tests pass. I did not run the whole suite; the forge's check does that.What changed
src/http/admin_gate.ts, sits inanswerGetafter the proposal-token gate and before any handler. It covers/admin/,/api/v1/admin/and/releaseswith its rollback POST.administergets the refusal. That includes a guest, since the table withholdsadministerfrom guests as well.{error: "not_admin", message}. A browser gets a 403 page with the same sentence.NOT_AN_ADMINinsrc/core/roles.ts: "only an admin can change the forge's settings or its releases".guard_guestsswitch, so with that off the old behaviour stands, as in the rest of the suite.docs/ROLES.mdhas a short part-3a note.test/admin_refused.test.tsis new. A member is refused nine admin API acts and the admin pages and POSTs (limits, quotas, signup) plus/releasesand its rollback. An admin succeeds on the sample reads I tried. GATE picks the file up automatically.What I left out
/releases.json, which stays public because a parent forge reads it./settings/*crew, cloud, backups and secrets pages, which keep their existing 404 for non-admins.Try it Run
bun test test/admin_refused.test.ts. Or turnguard_guestson, sign in as a member, and open/admin/limitsor/releases.🤖 Generated with Claude Code
Closes #2384