From 0f30143c5dd25c4c5e1bf4341a35847c99e684f3 Mon Sep 17 00:00:00 2001 From: Edwin van den Houdt Date: Thu, 23 Jul 2026 15:53:33 +0200 Subject: [PATCH] =?UTF-8?q?feat(privacy):=20WP-41=20=E2=80=94=20persisted,?= =?UTF-8?q?=20queryable=20authz/PII-reveal=20audit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Persist the security-relevant events (authz denials + BIG-nummer reveal/step-up) into a data-minimised EF table (AuthzAuditEntry: At/Action/Resource/Decision/Role/CorrelationId — never a name/BSN/value), extending the DocumentStore AuditEntry pattern (migration AuthzAudit). AuditAuthz now persists via AuthzAuditStore.Record alongside its log line. GET /admin/audit (admin-gated by the existing CasesAdmin) returns the trail newest-first. +3 backend tests incl. a schema-carries-no-PII reflection test. Typed client regenerated (audit() + AuthzAuditDto); no FE consumer yet (a future audit view must add the ROLE_AWARE prefix). Finishes WP-42's audit half. Co-Authored-By: Claude Opus 4.8 --- backend/src/BigRegister.Api/Contracts/Dtos.cs | 4 + .../src/BigRegister.Api/Data/AppDbContext.cs | 7 + .../BigRegister.Api/Data/AuthzAuditStore.cs | 49 ++++ .../20260723134832_AuthzAudit.Designer.cs | 260 ++++++++++++++++++ .../Migrations/20260723134832_AuthzAudit.cs | 40 +++ .../Migrations/AppDbContextModelSnapshot.cs | 34 +++ backend/src/BigRegister.Api/Program.cs | 11 + backend/swagger.json | 62 +++++ .../BigRegister.Tests/AuthzAuditTests.cs | 55 ++++ docs/project/backlog/README.md | 2 +- .../backlog/WP-41-persisted-authz-audit.md | 20 +- src/app/shared/infrastructure/api-client.ts | 51 ++++ 12 files changed, 590 insertions(+), 5 deletions(-) create mode 100644 backend/src/BigRegister.Api/Data/AuthzAuditStore.cs create mode 100644 backend/src/BigRegister.Api/Data/Migrations/20260723134832_AuthzAudit.Designer.cs create mode 100644 backend/src/BigRegister.Api/Data/Migrations/20260723134832_AuthzAudit.cs create mode 100644 backend/tests/BigRegister.Tests/AuthzAuditTests.cs diff --git a/backend/src/BigRegister.Api/Contracts/Dtos.cs b/backend/src/BigRegister.Api/Contracts/Dtos.cs index 2771cba..b9ce037 100644 --- a/backend/src/BigRegister.Api/Contracts/Dtos.cs +++ b/backend/src/BigRegister.Api/Contracts/Dtos.cs @@ -79,6 +79,10 @@ public sealed record IntakeRequest(int Uren); public sealed record HerregistratieRequest(int Uren, IReadOnlyList? Documents = null); public sealed record ChangeRequestRequest(string Telefoon); +// Authz/PII-reveal audit row (WP-41) — data-minimised, no PII (see AuthzAuditEntry). +public sealed record AuthzAuditDto( + string At, string Action, string Resource, string Decision, string Role, string CorrelationId); + public sealed record ReferentieResponse(string Referentie); // --- Applications (aanvragen): the system of record for the dashboard. --- diff --git a/backend/src/BigRegister.Api/Data/AppDbContext.cs b/backend/src/BigRegister.Api/Data/AppDbContext.cs index a7168a2..3eec246 100644 --- a/backend/src/BigRegister.Api/Data/AppDbContext.cs +++ b/backend/src/BigRegister.Api/Data/AppDbContext.cs @@ -19,6 +19,7 @@ public sealed class AppDbContext(DbContextOptions options) : DbCon { public DbSet Documents => Set(); public DbSet AuditEntries => Set(); + public DbSet AuthzAudit => Set(); public DbSet Applications => Set(); public DbSet Briefs => Set(); public DbSet OrgTemplates => Set(); @@ -33,6 +34,12 @@ public sealed class AppDbContext(DbContextOptions options) : DbCon e.Property(a => a.Id).ValueGeneratedOnAdd(); }); + modelBuilder.Entity(e => + { + e.HasKey(a => a.Id); + e.Property(a => a.Id).ValueGeneratedOnAdd(); + }); + modelBuilder.Entity(e => { e.HasKey(a => a.Id); diff --git a/backend/src/BigRegister.Api/Data/AuthzAuditStore.cs b/backend/src/BigRegister.Api/Data/AuthzAuditStore.cs new file mode 100644 index 0000000..6f05bba --- /dev/null +++ b/backend/src/BigRegister.Api/Data/AuthzAuditStore.cs @@ -0,0 +1,49 @@ +namespace BigRegister.Api.Data; + +/// +/// A persisted, DATA-MINIMISED authorization/PII-reveal audit entry (WP-41, PRD-0002 §8): +/// who (acting role, not identity), what action, on which resource ref, allow or deny, and +/// the correlation id — **never** a name, BSN, or the value that was (or wasn't) revealed. +/// Id is EF Core's auto-increment key (not positional), mirroring . +/// +public sealed record AuthzAuditEntry( + DateTimeOffset At, + string Action, + string Resource, + string Decision, + string Role, + string CorrelationId) +{ + public long Id { get; init; } +} + +/// +/// EF Core/SQLite-backed authz audit trail — the queryable twin of the log-only +/// AuditAuthz line. Same single-gate idiom as . Holds NO +/// PII by construction (see the entity); the schema test asserts it. +/// +public static class AuthzAuditStore +{ + private static readonly object _gate = new(); + + public static void Record(string action, string resource, bool allowed, string role, string correlationId) + { + lock (_gate) + { + using var db = Db.Create(); + db.AuthzAudit.Add(new AuthzAuditEntry( + DateTimeOffset.UtcNow, action, resource, allowed ? "allow" : "deny", role, correlationId)); + db.SaveChanges(); + } + } + + /// Newest first. Ordered client-side: SQLite can't ORDER BY a DateTimeOffset (WP-36). + public static IReadOnlyList List() + { + lock (_gate) + { + using var db = Db.Create(); + return db.AuthzAudit.ToList().OrderByDescending(a => a.At).ToList(); + } + } +} diff --git a/backend/src/BigRegister.Api/Data/Migrations/20260723134832_AuthzAudit.Designer.cs b/backend/src/BigRegister.Api/Data/Migrations/20260723134832_AuthzAudit.Designer.cs new file mode 100644 index 0000000..62e8c2d --- /dev/null +++ b/backend/src/BigRegister.Api/Data/Migrations/20260723134832_AuthzAudit.Designer.cs @@ -0,0 +1,260 @@ +// +using System; +using BigRegister.Api.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BigRegister.Api.Data.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20260723134832_AuthzAudit")] + partial class AuthzAudit + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "10.0.9"); + + modelBuilder.Entity("BigRegister.Api.Data.Aanvraag", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("AutoApprovable") + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("DocumentIds") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Draft") + .HasColumnType("TEXT"); + + b.Property("Owner") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Reden") + .HasColumnType("TEXT"); + + b.Property("Referentie") + .HasColumnType("TEXT"); + + b.Property("StepCount") + .HasColumnType("INTEGER"); + + b.Property("StepIndex") + .HasColumnType("INTEGER"); + + b.Property("Submitted") + .HasColumnType("INTEGER"); + + b.Property("SubmittedAt") + .HasColumnType("TEXT"); + + b.Property("Type") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Applications"); + }); + + modelBuilder.Entity("BigRegister.Api.Data.AuditEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Actor") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("At") + .HasColumnType("TEXT"); + + b.Property("CategoryId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("DocumentId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("AuditEntries"); + }); + + modelBuilder.Entity("BigRegister.Api.Data.AuthzAuditEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("At") + .HasColumnType("TEXT"); + + b.Property("CorrelationId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Decision") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Resource") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Role") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("AuthzAudit"); + }); + + modelBuilder.Entity("BigRegister.Api.Data.BriefEntity", b => + { + b.Property("BriefId") + .HasColumnType("TEXT"); + + b.Property("ArchivedHtml") + .HasColumnType("TEXT"); + + b.Property("Beroep") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("DrafterId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Owner") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Placeholders") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Sections") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("SentOrgTemplateVersion") + .HasColumnType("INTEGER"); + + b.Property("Status") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("SubOrgId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("TemplateId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("BriefId"); + + b.HasIndex("Owner") + .IsUnique(); + + b.ToTable("Briefs"); + }); + + modelBuilder.Entity("BigRegister.Api.Data.OrgTemplateEntity", b => + { + b.Property("SubOrgId") + .HasColumnType("TEXT"); + + b.Property("Draft") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("History") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PublishedVersion") + .HasColumnType("INTEGER"); + + b.HasKey("SubOrgId"); + + b.ToTable("OrgTemplates"); + }); + + modelBuilder.Entity("BigRegister.Api.Data.StoredDocument", b => + { + b.Property("DocumentId") + .HasColumnType("TEXT"); + + b.Property("CategoryId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Content") + .IsRequired() + .HasColumnType("BLOB"); + + b.Property("ContentType") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("FileName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Linked") + .HasColumnType("INTEGER"); + + b.Property("LocalId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Owner") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("SizeBytes") + .HasColumnType("INTEGER"); + + b.Property("UploadedAt") + .HasColumnType("TEXT"); + + b.Property("WizardId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("DocumentId"); + + b.ToTable("Documents"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/backend/src/BigRegister.Api/Data/Migrations/20260723134832_AuthzAudit.cs b/backend/src/BigRegister.Api/Data/Migrations/20260723134832_AuthzAudit.cs new file mode 100644 index 0000000..91847ca --- /dev/null +++ b/backend/src/BigRegister.Api/Data/Migrations/20260723134832_AuthzAudit.cs @@ -0,0 +1,40 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BigRegister.Api.Data.Migrations +{ + /// + public partial class AuthzAudit : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "AuthzAudit", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + At = table.Column(type: "TEXT", nullable: false), + Action = table.Column(type: "TEXT", nullable: false), + Resource = table.Column(type: "TEXT", nullable: false), + Decision = table.Column(type: "TEXT", nullable: false), + Role = table.Column(type: "TEXT", nullable: false), + CorrelationId = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AuthzAudit", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AuthzAudit"); + } + } +} diff --git a/backend/src/BigRegister.Api/Data/Migrations/AppDbContextModelSnapshot.cs b/backend/src/BigRegister.Api/Data/Migrations/AppDbContextModelSnapshot.cs index e89a2ac..7235c69 100644 --- a/backend/src/BigRegister.Api/Data/Migrations/AppDbContextModelSnapshot.cs +++ b/backend/src/BigRegister.Api/Data/Migrations/AppDbContextModelSnapshot.cs @@ -99,6 +99,40 @@ namespace BigRegister.Api.Data.Migrations b.ToTable("AuditEntries"); }); + modelBuilder.Entity("BigRegister.Api.Data.AuthzAuditEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("At") + .HasColumnType("TEXT"); + + b.Property("CorrelationId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Decision") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Resource") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Role") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("AuthzAudit"); + }); + modelBuilder.Entity("BigRegister.Api.Data.BriefEntity", b => { b.Property("BriefId") diff --git a/backend/src/BigRegister.Api/Program.cs b/backend/src/BigRegister.Api/Program.cs index 4f1b554..624a83f 100644 --- a/backend/src/BigRegister.Api/Program.cs +++ b/backend/src/BigRegister.Api/Program.cs @@ -330,6 +330,15 @@ api.MapDelete("/admin/cases/{id}", (string id, HttpContext ctx) => CasesAdmin(ct .Produces(StatusCodes.Status404NotFound) .ProducesProblem(StatusCodes.Status403Forbidden); +// Queryable authz/PII-reveal audit trail (WP-41) — data-minimised, no PII. Admin-gated +// via the existing CasesAdmin (cases:manage); a dedicated audit:read cap is a later refinement. +api.MapGet("/admin/audit", (HttpContext ctx) => CasesAdmin(ctx, () => + Results.Ok(AuthzAuditStore.List() + .Select(a => new AuthzAuditDto(a.At.ToString("o"), a.Action, a.Resource, a.Decision, a.Role, a.CorrelationId)) + .ToList()))) +.Produces>() +.ProducesProblem(StatusCodes.Status403Forbidden); + // PRD-0002 §6: coarse, role-derived capabilities for nav/menu-level checks (NOT // tied to a specific brief's live status — see BriefDecisionsDto for that). api.MapGet("/me", (HttpContext ctx) => new MeDto(Authz.RoleCapabilities(Authz.ResolvePrincipal(ctx)))) @@ -558,6 +567,8 @@ void AuditAuthz(HttpContext ctx, string action, string resource, bool allowed, P app.Logger.LogInformation( "authz action={Action} resource={Resource} decision={Decision} role={Role} correlationId={Cid}", action, resource, allowed ? "allow" : "deny", principal.Role, cid); + // Persist the queryable, data-minimised trail (WP-41) alongside the log line. + AuthzAuditStore.Record(action, resource, allowed, principal.Role.ToString(), cid); } // Keep the last `keep` characters, mask the rest — mirrors the FE maskTail diff --git a/backend/swagger.json b/backend/swagger.json index cf4ceef..e3ee165 100644 --- a/backend/swagger.json +++ b/backend/swagger.json @@ -801,6 +801,38 @@ } } }, + "/api/v1/admin/audit": { + "get": { + "tags": [ + "BigRegister.Api, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AuthzAuditDto" + } + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/problem+json": { + "schema": { + "$ref": "#/components/schemas/ProblemDetails" + } + } + } + } + } + } + }, "/api/v1/me": { "get": { "tags": [ @@ -1445,6 +1477,36 @@ }, "additionalProperties": false }, + "AuthzAuditDto": { + "type": "object", + "properties": { + "at": { + "type": "string", + "nullable": true + }, + "action": { + "type": "string", + "nullable": true + }, + "resource": { + "type": "string", + "nullable": true + }, + "decision": { + "type": "string", + "nullable": true + }, + "role": { + "type": "string", + "nullable": true + }, + "correlationId": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + }, "BriefDecisionsDto": { "type": "object", "properties": { diff --git a/backend/tests/BigRegister.Tests/AuthzAuditTests.cs b/backend/tests/BigRegister.Tests/AuthzAuditTests.cs new file mode 100644 index 0000000..a670bd1 --- /dev/null +++ b/backend/tests/BigRegister.Tests/AuthzAuditTests.cs @@ -0,0 +1,55 @@ +using System.Net; +using System.Net.Http.Json; +using System.Text.RegularExpressions; +using BigRegister.Api.Contracts; +using BigRegister.Api.Data; +using Microsoft.AspNetCore.Mvc.Testing; + +namespace BigRegister.Tests; + +/// WP-41: the persisted authz/PII-reveal audit trail is queryable, data-minimised (no PII). +public class AuthzAuditTests(TestWebApplicationFactory factory) : IClassFixture +{ + private readonly HttpClient _client = factory.CreateClient(); + + private HttpRequestMessage Admin(HttpMethod method, string path) + { + var req = new HttpRequestMessage(method, path); + req.Headers.Add("X-Role", "admin"); + return req; + } + + private async Task> AuditLog() + { + var res = await _client.SendAsync(Admin(HttpMethod.Get, "/api/v1/admin/audit")); + res.EnsureSuccessStatusCode(); + return (await res.Content.ReadFromJsonAsync>())!; + } + + [Fact] + public async Task A_denied_admin_action_is_recorded() + { + // No X-Role → drafter → 403 on an admin endpoint → a deny entry. + Assert.Equal(HttpStatusCode.Forbidden, (await _client.GetAsync("/api/v1/admin/cases")).StatusCode); + Assert.Contains(await AuditLog(), e => e.Action == "cases:manage" && e.Decision == "deny"); + } + + [Fact] + public async Task A_reveal_attempt_is_recorded() + { + // Drafter (capable role) without X-Step-Up → reveal denied → recorded. + var res = await _client.PostAsync("/api/v1/brief/reveal-bignummer", null); + Assert.Equal(HttpStatusCode.Forbidden, res.StatusCode); + Assert.Contains(await AuditLog(), e => e.Action == "brief:reveal-bignummer"); + } + + [Fact] + public void The_audit_schema_carries_no_pii() + { + var names = typeof(AuthzAuditEntry).GetProperties().Select(p => p.Name).ToArray(); + Assert.Equal( + new[] { "At", "Action", "Resource", "Decision", "Role", "CorrelationId", "Id" }.OrderBy(x => x), + names.OrderBy(x => x)); + Assert.DoesNotContain(names, n => Regex.IsMatch(n, "naam|name|bsn|value|waarde", RegexOptions.IgnoreCase)); + } +} diff --git a/docs/project/backlog/README.md b/docs/project/backlog/README.md index 5e27fdc..3f0e0d7 100644 --- a/docs/project/backlog/README.md +++ b/docs/project/backlog/README.md @@ -85,7 +85,7 @@ for its existing violations, so every WP ends green. | [WP-38](WP-38-dependency-graph-boundaries.md) | Dependency graph + declarative boundaries (visualize + enforce) | 8 · platform/DX/showcase | done | | [WP-39](WP-39-showcase-snippets-animations.md) | Showcase: linked code snippets + teaching animations | 8 · platform/DX/showcase | done | | [WP-40](WP-40-pii-kernel.md) | PII kernel: branded `Bsn` VO (elfproef) + masked-value atom | 8 · platform/DX/showcase | done | -| [WP-41](WP-41-persisted-authz-audit.md) | Persisted, queryable authz/PII-reveal audit (no PII) | 8 · platform/DX/showcase | todo | +| [WP-41](WP-41-persisted-authz-audit.md) | Persisted, queryable authz/PII-reveal audit (no PII) | 8 · platform/DX/showcase | done | | [WP-42](WP-42-privacy-security-showcase.md) | Privacy & security showcase page (mask + no-PII log) | 8 · platform/DX/showcase | partial | | [WP-43](WP-43-scaffold-generators.md) | Runnable generators: value-object / form-machine / bff-endpoint / ui-component | 8 · platform/DX/showcase | todo | | [WP-44](WP-44-context-generator.md) | Runnable generator: `gen:context` | 8 · platform/DX/showcase | todo | diff --git a/docs/project/backlog/WP-41-persisted-authz-audit.md b/docs/project/backlog/WP-41-persisted-authz-audit.md index 9cafbb3..4dfa7b3 100644 --- a/docs/project/backlog/WP-41-persisted-authz-audit.md +++ b/docs/project/backlog/WP-41-persisted-authz-audit.md @@ -1,10 +1,22 @@ # WP-41 — Persisted, queryable authz/PII-reveal audit -Status: todo +Status: done Phase: 8 — platform/DX/showcase Priority: P2 Depends on: WP-40 +## Outcome + +New data-minimised EF table `AuthzAuditEntry` (`Data/AuthzAuditStore.cs`, DbSet + key config in +`AppDbContext`, migration `AuthzAudit`): `At, Action, Resource, Decision, Role, CorrelationId` — +**never** a name/BSN/value. `AuditAuthz` now persists (via `AuthzAuditStore.Record`) alongside its +log line, so every authz denial + BIG-nummer reveal/step-up attempt is captured. `GET /admin/audit` +(admin-gated by the existing `CasesAdmin`/`cases:manage` — a dedicated `audit:read` cap is a later +refinement) returns the trail newest-first (client-side sort — SQLite can't ORDER BY DateTimeOffset). ++3 backend tests (deny recorded, reveal recorded, **schema-carries-no-PII** reflection test). Typed +client regenerated (`audit()` + `AuthzAuditDto`). No FE consumer yet — a future audit view (WP-42 +finish) must add `/api/v1/admin/audit` to the `role.interceptor` ROLE_AWARE list or it silently 403s. + ## Why The security-relevant events (authz denials via `AuditAuthz`, BIG-nummer reveal, step-up) are @@ -29,6 +41,6 @@ covers document lifecycle only. PRD-0002 §8 calls for a persisted authorization ## 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. +- [x] Denials, reveals, and step-up attempts land as rows with no PII/value fields. +- [x] A test asserts the schema carries no name/bsn/value column. +- [x] `dotnet test` (132) + `npm run ci` green; api-client drift clean after commit. diff --git a/src/app/shared/infrastructure/api-client.ts b/src/app/shared/infrastructure/api-client.ts index 43186d5..ed60fb5 100644 --- a/src/app/shared/infrastructure/api-client.ts +++ b/src/app/shared/infrastructure/api-client.ts @@ -1120,6 +1120,48 @@ export class ApiClient { return Promise.resolve(null as any); } + /** + * @return OK + */ + audit(): Promise { + let url_ = this.baseUrl + "/api/v1/admin/audit"; + url_ = url_.replace(/[?&]$/, ""); + + let options_: RequestInit = { + method: "GET", + headers: { + "Accept": "application/json" + } + }; + + return this.http.fetch(url_, options_).then((_response: Response) => { + return this.processAudit(_response); + }); + } + + protected processAudit(response: Response): Promise { + const status = response.status; + let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; + if (status === 200) { + return response.text().then((_responseText) => { + let result200: any = null; + result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as AuthzAuditDto[]; + return result200; + }); + } else if (status === 403) { + return response.text().then((_responseText) => { + let result403: any = null; + result403 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as ProblemDetails; + return throwException("Forbidden", status, _responseText, _headers, result403); + }); + } else if (status !== 200 && status !== 204) { + return response.text().then((_responseText) => { + return throwException("An unexpected server error occurred.", status, _responseText, _headers); + }); + } + return Promise.resolve(null as any); + } + /** * @return OK */ @@ -1765,6 +1807,15 @@ export interface ApplicationSummaryDto { owner?: string | undefined; } +export interface AuthzAuditDto { + at?: string | undefined; + action?: string | undefined; + resource?: string | undefined; + decision?: string | undefined; + role?: string | undefined; + correlationId?: string | undefined; +} + export interface BriefDecisionsDto { canEdit?: boolean; canApprove?: boolean;