feat: per-orbit access grants and an Access console (auth M5)

Authorization
- one gate for every human endpoint: authenticate, resolve the resource, then
  admin_only / scoped / visible; require_admin* removed so each handler must choose
- grants (user or IdP group; global or one orbit; optional end date) read live on
  every request; only orbit.read, snapshot.read, capture.run and snapshot.download
  can be granted, everything else stays with configured administrators
- an orbit without orbit.read is 404, a visible one without the permission is 403,
  a caller with nothing to see gets 403 on lists; job history is filtered before LIMIT
- jobs and audit record the stable principal id, not the IdP display name
- restore targets and restore history are admin-only until self-service (M6)
- sessions keep the groups verified at sign-in

Administration
- /api/v1/access grants and users (enable, disable, sign out everywhere), validated
  and audited by id; admins cannot disable themselves or the emergency operator
- Access console with the shared Select and a themed DatePicker; non-administrators
  only see Vault and Activity and never call administrator endpoints
- the Window/Radar view is stored per account (/api/v1/me/preferences)
- UI tolerates older hubs and mocks (missing admin/grants) and a console that fails
  to render no longer blanks the app

Tests: a matrix generated from the endpoint contract exercises every human route
against real resources in two orbits for each kind of caller.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 14:45:41 +07:00
parent 54abd02250
commit d12472ba02
29 changed files with 2284 additions and 169 deletions

View File

@@ -259,3 +259,34 @@ immediately. A denial is written to the audit log at most once a minute per sour
timestamp) and the hub refuses the token after that time. Without it the hub logs a
warning at start. Every use is audited as the `legacy-admin-token` service principal.
## Who may do what (access grants)
Administrators are the people named by the SSO admin mapping (`TESSERA_OIDC_ADMIN_SUBJECTS` /
`TESSERA_OIDC_ADMIN_GROUPS`), the emergency operator and the shared admin token. They can
do everything. Everyone else gets **nothing** until an administrator grants it in the
Access console (or through `/api/v1/access/*`). A grant names a person (a user who has signed
in) or an identity-provider group, a permission, an orbit (or all orbits) and optionally an end date.
Permissions that can be granted: `orbit.read`, `snapshot.read`, `capture.run`,
`snapshot.download`. They are separate: running a backup does not allow downloading it, and
the reverse. The roles `viewer`, `capturer` and `downloader` are shortcuts that expand into
these permissions, each including `orbit.read`. Everything else (creating or changing orbits,
profiles, Outposts, retention, deleting snapshots, restores, and access itself) stays with
administrators and cannot be delegated.
- An orbit a user has no `orbit.read` on is invisible: by id it answers `404`, in lists it is
left out. A visible orbit without the needed permission answers `403`. A user with no grant at
all gets `403` on lists and sees "No access yet" in the app.
- Grants are read on every request. Removing a grant, an expiry, disabling a user or
"Sign out everywhere" take effect on that user's next request. A change to a user's groups at
the identity provider applies at their next sign-in (at most 8 hours later), because groups
are taken from the sign-in token.
- A group grant applies to people whose token carries that group; a missing groups claim grants nothing.
- Jobs and audit entries record the stable user id (`oidc:<id>`), never the name the IdP reports.
- Until the self-service refresh arrives, restore targets and restore history are shown to
administrators only, because they describe the destination database.
- The administrator who disables a user cannot disable themselves or the emergency operator.
- Display choices (currently the Window/Radar view) are stored per account (`/api/v1/me/preferences`), so they follow
a person to another browser. Accounts without a user row (the shared admin token, local development) keep the
choice in the browser only.