# WP-41 — Persisted, queryable authz/PII-reveal audit Status: todo Phase: 8 — platform/DX/showcase Priority: P2 Depends on: WP-40 ## Why The security-relevant events (authz denials via `AuditAuthz`, BIG-nummer reveal, step-up) are **log-only** — never persisted, so there's no queryable trail. The one persisted `AuditEntry` table covers document lifecycle only. PRD-0002 §8 calls for a persisted authorization audit. A register (BIO) wants this queryable, and strictly data-minimised. ## Decisions - Persist authz/reveal/step-up events into a data-minimised EF table extending the existing `AuditEntry`/`AppDbContext` pattern: role, action, resource-ref, decision, correlation-id, timestamp — **never** the value or any PII. - Wire `AuditAuthz` + the reveal endpoint to persist (in addition to the log line). - Optional thin admin read view — reuse `cases:manage` or add an `audit:read` capability. ## Files - `backend/.../Data/` — new audit entity + `AppDbContext` DbSet + EF migration. - `backend/.../Program.cs` — `AuditAuthz` + reveal endpoint persist. - Backend tests: events are persisted; **no PII columns**; correlation-id captured. - (Optional) FE audit read page + adapter/store, gated by the capability. ## Acceptance criteria - [ ] Denials, reveals, and step-up attempts land as rows with no PII/value fields. - [ ] A test asserts the schema carries no name/bsn/value column. - [ ] `dotnet test` + `npm run ci` green; api-client drift clean if endpoints added.