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

@@ -17,12 +17,17 @@ export function SnapshotSheet({
siblings = [],
onReconstitute,
onDeleted,
canManage = false,
canDownload = false,
}: {
snap: Snapshot;
/** Every snapshot of the same orbit, newest first, including this one. */
siblings?: Snapshot[];
onReconstitute: () => void;
onDeleted: () => void;
/** Administrators only: restore and delete. */
canManage?: boolean;
canDownload?: boolean;
}) {
const [confirmDelete, setConfirmDelete] = useState(false);
const [copied, setCopied] = useState(false);
@@ -99,17 +104,17 @@ export function SnapshotSheet({
</div>
<div className="sheet-actions">
<Button variant="primary" className="sheet-primary" onClick={onReconstitute}>
{canManage && <Button variant="primary" className="sheet-primary" onClick={onReconstitute}>
{database ? "Database recovery options" : "Export file on hub"}
<span aria-hidden="true">→</span>
</Button>
<a href={`/api/v1/snapshots/${snap.id}/download`} download className="console-control sheet-link">
</Button>}
{canDownload && <a href={`/api/v1/snapshots/${snap.id}/download`} download className="console-control sheet-link">
Download snapshot
<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
<path d="M8 2v8M4.5 7 8 10.5 11.5 7M3 13.5h10" />
</svg>
</a>
{confirmDelete ? (
</a>}
{canManage && (confirmDelete ? (
<div className="sheet-confirm" role="alertdialog" aria-label="Confirm deletion">
<p>Remove this recovery point from the hub catalogue? This cannot be undone.</p>
{deletion.isError && <p role="alert" className="text-orbit-red">Snapshot could not be removed. It may be in use.</p>}
@@ -122,7 +127,7 @@ export function SnapshotSheet({
</div>
) : (
<button type="button" className="sheet-delete" onClick={() => setConfirmDelete(true)}>Delete snapshot</button>
)}
))}
</div>
<TelemetryPanel label="Snapshot record">{JSON.stringify(snap, null, 2)}</TelemetryPanel>
</div>