feat(acl): implement OpenZaak default-fill + ZGW gateway (refs #5)
AclService.OpenZaakAsync builds a ZaakRequest from the configured defaults (bronorganisatie, verantwoordelijkeOrganisatie, vertrouwelijkheidaanduiding, zaaktype) plus today's date from the clock, and delegates to the gateway. OpenZaakGateway POSTs the zaak to /zaken/api/v1/zaken with a ZGW Bearer JWT and the CRS headers, returning the created zaak URL. Tests pass (green). Add a root register-referentie.slnx (bff + acl) and point `make ci` at it so the gate covers every .NET service. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2
Makefile
2
Makefile
@@ -5,7 +5,7 @@
|
|||||||
# `make ci` locally runs exactly what the pipeline runs — no drift. Until a
|
# `make ci` locally runs exactly what the pipeline runs — no drift. Until a
|
||||||
# self-hosted runner is registered, `make ci` is the gate (see docs/runbooks/ci.md).
|
# self-hosted runner is registered, `make ci` is the gate (see docs/runbooks/ci.md).
|
||||||
|
|
||||||
SLN := services/bff/Bff.slnx
|
SLN := register-referentie.slnx
|
||||||
COMPOSE := infra/docker-compose.yml
|
COMPOSE := infra/docker-compose.yml
|
||||||
HEALTH_URL := http://localhost:8080/health
|
HEALTH_URL := http://localhost:8080/health
|
||||||
OZ_COMPOSE := infra/openzaak/docker-compose.yml
|
OZ_COMPOSE := infra/openzaak/docker-compose.yml
|
||||||
|
|||||||
13
register-referentie.slnx
Normal file
13
register-referentie.slnx
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<Solution>
|
||||||
|
<Folder Name="/services/" />
|
||||||
|
<Folder Name="/services/acl/">
|
||||||
|
<Project Path="services/acl/Acl.Api/Acl.Api.csproj" />
|
||||||
|
<Project Path="services/acl/Acl.Application/Acl.Application.csproj" />
|
||||||
|
<Project Path="services/acl/Acl.Infrastructure/Acl.Infrastructure.csproj" />
|
||||||
|
<Project Path="services/acl/Acl.Tests/Acl.Tests.csproj" />
|
||||||
|
</Folder>
|
||||||
|
<Folder Name="/services/bff/">
|
||||||
|
<Project Path="services/bff/Bff.Api/Bff.Api.csproj" />
|
||||||
|
<Project Path="services/bff/Bff.Tests/Bff.Tests.csproj" />
|
||||||
|
</Folder>
|
||||||
|
</Solution>
|
||||||
@@ -5,5 +5,16 @@ namespace Acl.Application;
|
|||||||
public sealed class AclService(IZaakGateway gateway, AclDefaults defaults, IClock clock)
|
public sealed class AclService(IZaakGateway gateway, AclDefaults defaults, IClock clock)
|
||||||
{
|
{
|
||||||
public Task<Uri> OpenZaakAsync(DomainRegistration registration, CancellationToken ct = default)
|
public Task<Uri> OpenZaakAsync(DomainRegistration registration, CancellationToken ct = default)
|
||||||
=> throw new NotImplementedException();
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(registration);
|
||||||
|
|
||||||
|
var request = new ZaakRequest(
|
||||||
|
defaults.Bronorganisatie,
|
||||||
|
defaults.VerantwoordelijkeOrganisatie,
|
||||||
|
defaults.Vertrouwelijkheidaanduiding,
|
||||||
|
defaults.ZaaktypeUrl,
|
||||||
|
clock.Today);
|
||||||
|
|
||||||
|
return gateway.OpenZaakAsync(request, ct);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Net.Http.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using Acl.Application;
|
using Acl.Application;
|
||||||
|
|
||||||
namespace Acl.Infrastructure;
|
namespace Acl.Infrastructure;
|
||||||
@@ -5,6 +8,41 @@ namespace Acl.Infrastructure;
|
|||||||
/// <summary>The only code that talks to OpenZaak's Zaken API (ADR-0001).</summary>
|
/// <summary>The only code that talks to OpenZaak's Zaken API (ADR-0001).</summary>
|
||||||
public sealed class OpenZaakGateway(HttpClient http, OpenZaakOptions options) : IZaakGateway
|
public sealed class OpenZaakGateway(HttpClient http, OpenZaakOptions options) : IZaakGateway
|
||||||
{
|
{
|
||||||
public Task<Uri> OpenZaakAsync(ZaakRequest request, CancellationToken ct = default)
|
public async Task<Uri> OpenZaakAsync(ZaakRequest request, CancellationToken ct = default)
|
||||||
=> throw new NotImplementedException();
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(request);
|
||||||
|
|
||||||
|
using var message = new HttpRequestMessage(
|
||||||
|
HttpMethod.Post, new Uri(options.BaseUrl, "/zaken/api/v1/zaken"))
|
||||||
|
{
|
||||||
|
Content = JsonContent.Create(new ZaakDto(
|
||||||
|
request.Bronorganisatie,
|
||||||
|
request.Zaaktype.ToString(),
|
||||||
|
request.VerantwoordelijkeOrganisatie,
|
||||||
|
request.Startdatum.ToString("yyyy-MM-dd"),
|
||||||
|
request.Vertrouwelijkheidaanduiding)),
|
||||||
|
};
|
||||||
|
message.Headers.Authorization =
|
||||||
|
new AuthenticationHeaderValue("Bearer", ZgwToken.Mint(options.ClientId, options.Secret));
|
||||||
|
// ZRC is a geo API; it requires the CRS headers.
|
||||||
|
message.Headers.Add("Accept-Crs", "EPSG:4326");
|
||||||
|
message.Content.Headers.Add("Content-Crs", "EPSG:4326");
|
||||||
|
|
||||||
|
using var response = await http.SendAsync(message, ct);
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
|
var created = await response.Content.ReadFromJsonAsync<ZaakCreatedDto>(ct)
|
||||||
|
?? throw new InvalidOperationException("OpenZaak returned an empty zaak response");
|
||||||
|
return new Uri(created.Url);
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed record ZaakDto(
|
||||||
|
[property: JsonPropertyName("bronorganisatie")] string Bronorganisatie,
|
||||||
|
[property: JsonPropertyName("zaaktype")] string Zaaktype,
|
||||||
|
[property: JsonPropertyName("verantwoordelijkeOrganisatie")] string VerantwoordelijkeOrganisatie,
|
||||||
|
[property: JsonPropertyName("startdatum")] string Startdatum,
|
||||||
|
[property: JsonPropertyName("vertrouwelijkheidaanduiding")] string Vertrouwelijkheidaanduiding);
|
||||||
|
|
||||||
|
private sealed record ZaakCreatedDto(
|
||||||
|
[property: JsonPropertyName("url")] string Url);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user