● Increment 1 complete. Marking it done. #37
No reviewers
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
rust
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
navicore/anz!37
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "remote"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
● What landed:
Piece: Config fields + per-realm TTL helpers
File: src/config.rs
Notes: admin_bind_address, admin_realm (default "master"), admin_access_token_lifetime_secs,
admin_refresh_token_lifetime_secs; access_token_lifetime_for(realm) / refresh_token_lifetime_for(realm)
────────────────────────────────────────
Piece: Forbidden 403 variant
File: src/server/error.rs
Notes: distinct from Unauthorized (401)
────────────────────────────────────────
Piece: Per-realm lifetimes wired
File: src/server/token.rs
Notes: all 3 grant paths (auth_code, refresh, client_credentials) + their expires_in
────────────────────────────────────────
Piece: State/router split
File: src/server/mod.rs
Notes: build_state + oidc_router are the real API now; build_router kept #[cfg(test)] so existing tests are
byte-for-byte untouched
────────────────────────────────────────
Piece: Admin module
File: src/server/admin/mod.rs
Notes: ANZ_ADMIN_GROUP constant, AdminContext extractor doing live-state authz (signature → issuer → kid → load
user fresh → realm + enabled + group check), admin_router with /admin/health (open) and /admin/whoami (authed)
────────────────────────────────────────
Piece: Dual-listener serve
File: src/cli/serve.rs
Notes: try_join! when admin_bind_address set; identical to before when unset
Posture verified by tests (125 passing, clippy clean with -D warnings):
guard)
realms keep long ones
Nothing observable changes for current deployments — without admin_bind_address in config, no second listener
starts and no /admin/* exists. Today's behavior is byte-for-byte preserved.
Ready to start Increment 2 (shared DTO module + read-only admin endpoints: list
realms/users/clients/keys/sessions). That increment is still server-side only — no CLI changes — and it's where
the request/response types that the CLI backend will share get defined.
● What landed: Piece: Config fields + per-realm TTL helpers File: src/config.rs Notes: admin_bind_address, admin_realm (default "master"), admin_access_token_lifetime_secs, admin_refresh_token_lifetime_secs; access_token_lifetime_for(realm) / refresh_token_lifetime_for(realm) ──────────────────────────────────────── Piece: Forbidden 403 variant File: src/server/error.rs Notes: distinct from Unauthorized (401) ──────────────────────────────────────── Piece: Per-realm lifetimes wired File: src/server/token.rs Notes: all 3 grant paths (auth_code, refresh, client_credentials) + their expires_in ──────────────────────────────────────── Piece: State/router split File: src/server/mod.rs Notes: build_state + oidc_router are the real API now; build_router kept #[cfg(test)] so existing tests are byte-for-byte untouched ──────────────────────────────────────── Piece: Admin module File: src/server/admin/mod.rs Notes: ANZ_ADMIN_GROUP constant, AdminContext extractor doing live-state authz (signature → issuer → kid → load user fresh → realm + enabled + group check), admin_router with /admin/health (open) and /admin/whoami (authed) ──────────────────────────────────────── Piece: Dual-listener serve File: src/cli/serve.rs Notes: try_join! when admin_bind_address set; identical to before when unset Posture verified by tests (125 passing, clippy clean with -D warnings): - admin acceptance — valid token + anz-admin group → 200 - 401 on missing token - 401 on token signed by a non-admin realm (issuer + kid mismatch) - 403 on valid admin-realm-signed token whose sub is in a different realm carrying anz-admin (the realm-binding guard) - 403 on no group - 403 on disabled admin - per-realm TTL helpers fall back to global when override unset; admin realm gets short lifetimes while app realms keep long ones Nothing observable changes for current deployments — without admin_bind_address in config, no second listener starts and no /admin/* exists. Today's behavior is byte-for-byte preserved. Ready to start Increment 2 (shared DTO module + read-only admin endpoints: list realms/users/clients/keys/sessions). That increment is still server-side only — no CLI changes — and it's where the request/response types that the CLI backend will share get defined.Review: Increment 1 — admin API foundation
Verdict: solid, ready to merge. Tightly-scoped, well-tested foundation. It does exactly what it claims, and nothing observable changes for current deployments (no
admin_bind_address→ no second listener, no/admin/*). Verified locally: clippy clean with-D warnings, all 125 tests pass.Verified against the code
realmintoken.rsis the realm name (Path(realm)), soaccess_token_lifetime_for(realm)/refresh_token_lifetime_for(realm)get the right argument in all three grant paths, andexpires_innow reflects the effective lifetime rather than the global one. Consistent across auth_code / refresh / client_credentials.decode_access_tokenvalidates issuer (set_issuer) and matcheskid, so the "reject tokens from any other realm" claim holds two ways over — wrongissand wrongkid.get_all_keysreturns active + deactivated keys (no active filter), so a token signed by a since-rotated admin key still verifies until hard-delete — matching the comment.authorize_adminfails closed: realm-binding (realm_id == admin_realm.id),!disabled, andanz-admingroup all checked against fresh DB state, not token claims. The 401 (bad/missing/foreign-signed token) vs 403 (valid token, not an admin) split is clean.Test coverage is the strong point
The adversarial cases that matter are all present — notably
whoami_rejects_admin_group_in_foreign_realm(admin-realm-signed token whosesublives in another realm but carriesanz-admin) exercises exactly the realm-binding guard a naive implementation would miss. Plus disabled, no-group, missing-token, and foreign-realm-signed.Worth noting (none blocking — forward-looking)
admin_access_deniedshould be audited on 403. The security boundary (the extractor) lands now, so logging denied 401/403 attempts on this high-value surface arguably belongs in Increment 1 rather than waiting for the operation endpoints. Currently onlyTraceLayercovers it.Forbidden("admin realm not provisioned")returns 403 for a missing admin realm — a server misconfiguration conflated with an authz denial. Fail-closed is safe, so this is a nitpick, but 401/500 might read truer.