Skip to content

fix(authz): widen fulla-admin-console allowlist for delegated admin sign-in - #386

Merged
voidvec merged 2 commits into
masterfrom
fix/375-admin-console-delegated-scopes
Nov 29, 2026
Merged

voidvec merged 2 commits into
masterfrom
fix/375-admin-console-delegated-scopes

Conversation

@voidvec

@voidvec voidvec commented Nov 29, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #375: the AF-01 delegated-administration sign-in was rejected end to end because the shipped fulla-admin-console OAuth2 client allowed only openid profile admin, so /oauth2/login dropped all nine V045 resource scopes at the client-allowlist tier and every delegated account was issued no admin-class scope (all console probes 403).

  • Widen allowed_scopes to the twelve login scopes in all five server configs (config.{json,dev.json,prod.json,ci.json,bench.json}); mirror the list in apps/server/seed/dev_admin_console_client.sql.
  • rbac_rules posture (per-environment decision requested by the issue): config.dev.json gains the "/api/admin/users.*": { "permissions": ["users:read"] } entry, aligning dev with config.json (dev is Postgres-backed and is the stack delegated sign-in is exercised on). ci/prod/bench stay operator opt-in: ci is memory-storage where delegated accounts cannot exist (role→permission resolution falls back to the compile-time map with no permission rows), and prod/bench are deployment choices.
  • frontends/admin/src/stores/auth.ts: the CONSOLE_LOGIN_SCOPE comment now states the shipped allowlist covers all twelve names and entitlements alone decide the issued subset (narrowing it back re-enables the client-tier drop).
  • AdminRbacEnforcementHttpTest.cc: three new legs exercise the red line through the shipped client (in addition to the existing dynamic-client legs), plus a introspectGrantedScope helper.

ClientSeeder backfill (issue AC #2, verified locally)

Against an existing Postgres DB whose oauth2_client_scopes still held the pre-change 3-row shape, one server boot with the widened config converged it to 12 rows — ClientSeeder: client 'fulla-admin-console' already present, left untouched (the afterClientRow path runs on ON CONFLICT DO NOTHING), with existing oauth2_clients fields unaltered. Fresh databases get the same list via the updated seed SQL. Note: the test binary does not run the seeder (it is wired in apps/server/src/main.cc bootstrap only) — CI's Postgres-backed suite relies on the seeded DB, which is why the seed SQL change is load-bearing there.

Validation

  • Integration_P1_Rbac_HelpdeskRedLine_AllThreeGates (now 58 assertions incl. the three new legs): all pass locally against Postgres — helpdesk (users:read-only) via client_id=fulla-admin-console receives exactly openid profile users:read, reads /api/admin/users (200), gets 403 on other admin families; an unprivileged account obtains no admin-class scope; the admin role's sign-in carries all twelve scopes and still passes the catch-all gate.
  • Integration_P1_Rbac_NegativeLine_UserRoleGrantNoGateCollapse: all pass (13 assertions).
  • No test in the tree asserts the shipped client's scope set (swept), and existing admin logins request only openid profile admin, so the widened allowlist does not change any other token's scope.
  • All five configs JSON-validated.
  • Regression sweep for token-scope exact-equality assertions found only client-credentials / explicit-request flows, unaffected.

Fixes #375

…ign-in

The AF-01 frontend half (Phase 1+2, #379) requests the nine V045 resource
scopes at console sign-in, but the shipped fulla-admin-console client only
allowed openid/profile/admin: /oauth2/login dropped every resource scope at
the client-allowlist tier, leaving delegated accounts with no admin-class
scope and refusing the sign-in end to end.

- Widen allowed_scopes to the twelve login scopes in all five server
  configs and mirror the list in dev_admin_console_client.sql. Existing
  Postgres deployments backfill the new oauth2_client_scopes rows
  idempotently at server restart via ClientSeeder (verified locally: a
  3-row pre-change DB converged to 12 rows on boot; afterClientRow runs
  on ON CONFLICT DO NOTHING).
- config.dev.json: add the /api/admin/users.* permissions rbac_rules
  entry, aligning dev with config.json so delegated tokens pass
  AuthorizationFilter out of the box. ci/prod/bench stay operator opt-in
  (ci is memory-storage, where delegated accounts cannot exist).
- auth.ts: refresh the CONSOLE_LOGIN_SCOPE comment; the shipped allowlist
  now covers all twelve names, entitlements alone decide the issued set.
- AdminRbacEnforcementHttpTest: exercise the red line through the SHIPPED
  client - a users:read-only helpdesk account gets exactly
  openid/profile/users:read (read users OK, everything else 403); an
  unprivileged account obtains no admin-class scope; the admin role's own
  sign-in carries all twelve scopes and still passes the family gate.

Fixes #375
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-29T03:04:23.614927Z
We couldn’t complete this review. Comment @codex review to try again.
e947ed7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@voidvec

voidvec commented Nov 29, 2026

Copy link
Copy Markdown
Owner Author

Review — no blocking issues; one important test-robustness note

The change itself looks correct and internally consistent:

  • Rule ordering is safe: AuthorizationFilter stable-sorts rules by pattern length, so the new "/api/admin/users.*" (19 chars) still wins over "/api/admin/.*" (14) regardless of JSON key order.
  • Entitlement intersection still decides the issued set, and the admin role carries all twelve permissions per V043, so widening fulla-admin-console.allowed_scopes does not widen what a plain user or helpdesk can hold.
  • The scope gate (users:read for GET, users:write for writes, impliedBy: admin) still backstops the RBAC rule, so the permission-only dev rule does not open the write methods.

Important — leg 8 bypasses the suite's login hardening. tests/integration/admin/AdminRbacEnforcementHttpTest.cc:219

loginForClient("admin", "admin", "fulla-admin-console", kFullConsoleScope);

is the only admin login in the suite that goes through the raw loginForClient helper. Every other admin login uses loginAsUserTokens() (tests/common/HttpTestClient.h:549), which adds two protections this call does not have:

  1. it resets failed_login_count / locked_until for admin — the documented "rotating loginAsAdmin empty" jitter when other suites trip the lockout threshold;
  2. it retries the whole PKCE flow once on failure.

loginAsUserTokens already targets kAdminClientId = "fulla-admin-console" with the same redirect URI, so leg 8 can simply use loginAsUserTokens("admin", "admin", kFullConsoleScope). As written, this leg is a new realistic flake source in an already large ctest suite.

Minor (non-blocking): the introspectGrantedScope(...).find("...") == npos assertions are substring checks; an exact set comparison (sort + ==) would pin the contract harder. Current form is acceptable.

@voidvec
voidvec merged commit 31214d4 into master Nov 29, 2026
16 checks passed
@voidvec
voidvec deleted the fix/375-admin-console-delegated-scopes branch December 2, 2026 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

config(authz): widen fulla-admin-console allowed_scopes for delegated admin sign-in (AF-01)

1 participant