Files
apf_portal/apps/portal-admin
Julien Gautier 283c68d7f0
CI / scan (pull_request) Successful in 4m41s
CI / commits (pull_request) Successful in 5m20s
CI / check (pull_request) Failing after 5m34s
CI / a11y (pull_request) Successful in 3m6s
CI / perf (pull_request) Successful in 9m11s
feat(admin): add /admin/users/:oid/scopes screen + endpoints (ADR-0026 PR 2b)
Backend
-------
New REST surface at /api/admin/users/:oid/scopes guarded by
@RequireAdmin (Portal.Admin privilege per ADR-0020). Three endpoints:

  GET    list a user's scopes with the linked User + Person info
         (no audit on reads)
  POST   grant a new scope - validates kind via SCOPE_KINDS catalogue,
         validates value against Structure.code / Delegation.code /
         Region.code for value-bearing kinds, rejects non-empty values
         for valueless kinds, translates Prisma P2002 to a 400 with
         "already granted"; emits admin.scope_granted (blocking
         audit per ADR-0013)
  DELETE :scopeId  404-protected against cross-user revocation;
         emits admin.scope_revoked with the resolved tuple at the
         moment of deletion

Two new audit types (AdminScopeGrantedInput / AdminScopeRevokedInput)
+ two AuditWriter methods. subject = "user:<oid>" so an auditor
pivots on the target of the change.

UserScope rows created here use source = "admin-ui" (distinct from
seed-written "seed" and Person-only "self-signin").

Frontend
--------
New Angular page at /admin/users/:oid/scopes (lazy-loaded). Lists
current scopes in a table with per-row Revoke buttons; "Grant a new
scope" form with kind dropdown + conditional value input + optional
expiresAt datetime. Friendly error mapping: 403 -> "no admin access",
404 -> "User not found, has this persona ever signed in or been
seeded?", server messages forwarded.

A11y per ADR-0016: aria-labelledby on form sections, role="status"
/ aria-live="polite" for load/error feedback, role="alert" for
submit errors, min-height 44px on every input/button, aria-label
on the Manage-scopes link carrying the user's displayName,
conditional aria-required + aria-describedby on the value input.

"Manage scopes" link added to each row of the existing /admin/users
list, navigating to the new page via the user's Entra oid.

Local: drift gate 4/24/7/3 clean; portal-bff lint 0 err; portal-admin
lint 0 err; both test suites green (portal-admin 71 tests, +8 for
user-scopes).

Closes the ADR-0026 trilogy alongside PRs #232 and #233. ADR-0025's
@RequireScope stack is now end-to-end live for the test tenant.
2026-05-26 15:39:50 +02:00
..