## What & why S-15a, the first of the S-15 (#16) split. A new **beheer** portal (medewerker realm, like behandel) shows the ZTC catalogus — the published zaaktypen — **read-only**. A beheerder logs in and sees the seeded BIG-REGISTRATIE zaaktype. Closes #130 ### The vertical portal → BFF `GET /beheer/catalogi/zaaktypen` (medewerker realm + `beheerder` role) → ACL `GET /catalogi/zaaktypen` → ZGW Catalogi API. - **ACL**: new read-only `GET /catalogi/zaaktypen` listing published zaaktypen (reuses the ADR-0021 Catalogi client; public-safe `identificatie`/`omschrijving`). - **BFF**: new typed `IAclClient` + `Downstream:Acl:BaseUrl`, and `GET /beheer/catalogi/zaaktypen` behind a new `beheerder` policy (reuses the medewerker bearer scheme + realm-role lifting). OpenAPI spec + generated Angular client regenerated. - **Keycloak**: `beheerder` realm role + `bram-beheerder` test user in the medewerker realm. - **Frontend**: new `apps/beheer` Angular app (copied from behandel) with a read-only catalogus page; `SECURE_API_ROUTES=['/beheer/']`. - **Infra**: `beheer` compose service (port 8143), added to `WAIT_SVCS` + CI log-dump; a Playwright e2e (beheerder login → catalogus shows BIG-REGISTRATIE). ### New boundary → ADR-0025 The BFF now reaches the **ACL directly** for the catalogus read — a new service-to-service edge (§14). The catalogus is neither a domain nor a projection concern, and §8.1 means only the ACL may read ZGW; routing through the domain would pollute it with a non-domain passthrough. §8.1/§8.3 stay intact. Recorded in **ADR-0025**. ## Definition of Done - [x] Failing test committed before each implementation (red→green per layer: ACL, BFF, frontend). - [x] Conventional Commits referencing #130. - [ ] CI green — pending Gitea Actions run. - [x] `docker compose up` brings up `beheer` (health-gated in `WAIT_SVCS`). - [x] Docs — ADR-0025 + demo-script S-15a note. - [x] Demo note in `docs/demo-script.md`. ## Verified locally lint (`dotnet format`) ✓ · .NET unit (Acl 57 / Big 152 / EventSubscriber 19 / Bff 40) ✓ · frontend lint+test (8 projects) ✓ · frontend build (4 apps) ✓. Mutation ratchet: added a gateway unit test for the new `ListZaaktypenAsync` mapping so the ACL score holds. verify-stack (compose smoke + e2e) runs in CI. ## Notes for reviewers - The BFF drops the ZGW URL from `BeheerZaaktype` (public-safe: identificatie + omschrijving only). - The catalogus e2e asserts on the stable seeded `BIG-REGISTRATIE` (not a per-test reference), safe on the shared verify stack. - Follow-ups: **S-15b** (#131) default-fill CRUD, **S-15c** (#132) medewerker-realm MFA. 🤖 Generated with [Claude Code](https://claude.com/claude-code)Reviewed-on: #133
107 lines
5.1 KiB
C#
107 lines
5.1 KiB
C#
using Acl.Application;
|
|
using Acl.Infrastructure;
|
|
using OpenTelemetry.Metrics;
|
|
using OpenTelemetry.Resources;
|
|
using OpenTelemetry.Trace;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// OpenTelemetry tracing (S-16b, ADR-0023): auto-instrument incoming ASP.NET Core requests and
|
|
// outgoing HttpClient calls (the ACL → OpenZaak hop), exported over OTLP to Tempo. Service name +
|
|
// OTLP endpoint come from OTEL_* env (compose); the exporter no-ops when Tempo is unreachable.
|
|
builder.Services.AddOpenTelemetry()
|
|
.ConfigureResource(r => r.AddService(
|
|
builder.Configuration["OTEL_SERVICE_NAME"] ?? builder.Environment.ApplicationName))
|
|
.WithTracing(tracing => tracing
|
|
.AddAspNetCoreInstrumentation(o => o.Filter = ctx => ctx.Request.Path != "/health")
|
|
.AddHttpClientInstrumentation()
|
|
.AddOtlpExporter())
|
|
// OpenTelemetry metrics (S-16c, ADR-0023): golden signals for the request path —
|
|
// http.server.request.duration (traffic/errors/latency) + http.client.* for downstream hops, plus
|
|
// the built-in System.Runtime meter for saturation (GC, CPU, thread pool). Prometheus scrapes these
|
|
// from /metrics (mapped below); metrics aren't pushed over OTLP, so no collector hop (ADR-0023).
|
|
.WithMetrics(metrics => metrics
|
|
.AddAspNetCoreInstrumentation()
|
|
.AddHttpClientInstrumentation()
|
|
.AddMeter("System.Runtime")
|
|
.AddPrometheusExporter());
|
|
|
|
builder.Services.AddSingleton<IClock, SystemClock>();
|
|
builder.Services.AddSingleton(sp => sp.GetRequiredService<IConfiguration>()
|
|
.GetSection("Acl:Defaults").Get<AclDefaults>()
|
|
?? throw new InvalidOperationException("Missing configuration section 'Acl:Defaults'"));
|
|
builder.Services.AddSingleton(sp => sp.GetRequiredService<IConfiguration>()
|
|
.GetSection("Acl:OpenZaak").Get<OpenZaakOptions>()
|
|
?? throw new InvalidOperationException("Missing configuration section 'Acl:OpenZaak'"));
|
|
builder.Services.AddHttpClient<IZaakGateway, OpenZaakGateway>();
|
|
// Singleton so the resolved zaaktype/informatieobjecttype URLs are cached across requests (S-27).
|
|
builder.Services.AddSingleton<IZaaktypeCatalog, CachedZaaktypeCatalog>();
|
|
builder.Services.AddScoped<AclService>();
|
|
|
|
var app = builder.Build();
|
|
|
|
app.MapGet("/health", () => "Healthy");
|
|
|
|
// Prometheus scrape endpoint (S-16c): exposes the OTel metrics above in Prometheus text format.
|
|
app.MapPrometheusScrapingEndpoint();
|
|
|
|
// The ACL's single operation, exposed as a service endpoint.
|
|
app.MapPost("/zaken", async (OpenZaakRequest body, AclService acl, CancellationToken ct) =>
|
|
{
|
|
var zaakUrl = await acl.OpenZaakAsync(new DomainRegistration(body.Bsn, body.Reference), ct);
|
|
return Results.Ok(new { zaakUrl = zaakUrl.ToString() });
|
|
});
|
|
|
|
// Approve a zaak: set it to its zaaktype's eindstatus (S-09b). The domain hands over only the zaak
|
|
// URL; the ACL owns the ZGW statustype resolution (§8.1).
|
|
app.MapPost("/statussen", async (SetStatusRequest body, AclService acl, CancellationToken ct) =>
|
|
{
|
|
await acl.ApproveZaakAsync(new Uri(body.ZaakUrl), ct);
|
|
return Results.NoContent();
|
|
});
|
|
|
|
// Cancel a zaak on document-timeout expiry (S-10c): set it to its zaaktype's cancellation statustype
|
|
// + resultaat. The domain hands over only the zaak URL; the ACL owns the ZGW resolution (§8.1).
|
|
app.MapPost("/annuleringen", async (CancelZaakRequest body, AclService acl, CancellationToken ct) =>
|
|
{
|
|
await acl.CancelZaakAsync(new Uri(body.ZaakUrl), ct);
|
|
return Results.NoContent();
|
|
});
|
|
|
|
// Read a zaak's public-safe reference (its identificatie). The Event Subscriber calls this to enrich
|
|
// the read projection without reading ZGW itself (§8.1, #78).
|
|
app.MapPost("/zaken/reference", async (ZaakReferenceRequest body, AclService acl, CancellationToken ct) =>
|
|
{
|
|
var reference = await acl.GetZaakReferenceAsync(new Uri(body.ZaakUrl), ct);
|
|
return Results.Ok(new { reference });
|
|
});
|
|
|
|
// Store an uploaded diploma against a zaak (S-10b): the domain sends the file as base64; the ACL
|
|
// creates the ZGW enkelvoudiginformatieobject and relates it to the zaak (§8.1). Returns its URL.
|
|
app.MapPost("/documenten", async (StoreDocumentRequest body, AclService acl, CancellationToken ct) =>
|
|
{
|
|
var url = await acl.StoreDiplomaAsync(
|
|
new Uri(body.ZaakUrl), Convert.FromBase64String(body.ContentBase64), body.FileName, body.ContentType, ct);
|
|
return Results.Ok(new { informatieobjectUrl = url.ToString() });
|
|
});
|
|
|
|
// List the published zaaktypen — the read-only catalogus the beheer portal shows (S-15a). The BFF
|
|
// proxies this behind medewerker-realm + beheerder authorization; the ACL trusts its callers (§8.3)
|
|
// and is the only code allowed to read the ZGW Catalogi API (§8.1).
|
|
app.MapGet("/catalogi/zaaktypen", async (AclService acl, CancellationToken ct) =>
|
|
Results.Ok(await acl.ListZaaktypenAsync(ct)));
|
|
|
|
app.Run();
|
|
|
|
public sealed record OpenZaakRequest(string Bsn, string Reference);
|
|
|
|
public sealed record SetStatusRequest(string ZaakUrl);
|
|
|
|
public sealed record CancelZaakRequest(string ZaakUrl);
|
|
|
|
public sealed record ZaakReferenceRequest(string ZaakUrl);
|
|
|
|
public sealed record StoreDocumentRequest(string ZaakUrl, string ContentBase64, string FileName, string ContentType);
|
|
|
|
public partial class Program;
|