feat(bff): GET /beheer/catalogi/zaaktypen proxies the ACL for beheerders (refs #130)
This commit is contained in:
@@ -24,6 +24,11 @@ import {
|
|||||||
Observable
|
Observable
|
||||||
} from 'rxjs';
|
} from 'rxjs';
|
||||||
|
|
||||||
|
export interface BeheerZaaktype {
|
||||||
|
identificatie: string;
|
||||||
|
omschrijving: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface CurrentRegistration {
|
export interface CurrentRegistration {
|
||||||
registrationId: string;
|
registrationId: string;
|
||||||
status: string;
|
status: string;
|
||||||
@@ -410,4 +415,35 @@ export class BffApiV1Service {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getBeheerCatalogiZaaktypen<TData = BeheerZaaktype[]>( options?: HttpClientBodyOptions): Observable<TData>;
|
||||||
|
getBeheerCatalogiZaaktypen<TData = BeheerZaaktype[]>( options?: HttpClientEventOptions): Observable<HttpEvent<TData>>;
|
||||||
|
getBeheerCatalogiZaaktypen<TData = BeheerZaaktype[]>( options?: HttpClientResponseOptions): Observable<AngularHttpResponse<TData>>;
|
||||||
|
getBeheerCatalogiZaaktypen<TData = BeheerZaaktype[]>(
|
||||||
|
options?: HttpClientObserveOptions): Observable<TData | HttpEvent<TData> | AngularHttpResponse<TData>> {
|
||||||
|
if (options?.observe === 'events') {
|
||||||
|
return this.http.get<TData>(
|
||||||
|
`/beheer/catalogi/zaaktypen`,{
|
||||||
|
...(options as Omit<NonNullable<typeof options>, 'observe'>),
|
||||||
|
observe: 'events',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options?.observe === 'response') {
|
||||||
|
return this.http.get<TData>(
|
||||||
|
`/beheer/catalogi/zaaktypen`,{
|
||||||
|
...(options as Omit<NonNullable<typeof options>, 'observe'>),
|
||||||
|
observe: 'response',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.http.get<TData>(
|
||||||
|
`/beheer/catalogi/zaaktypen`,{
|
||||||
|
...(options as Omit<NonNullable<typeof options>, 'observe'>),
|
||||||
|
observe: 'body',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ var domainBaseUrl = builder.Configuration["Downstream:Domain:BaseUrl"]
|
|||||||
?? throw new InvalidOperationException("Missing configuration 'Downstream:Domain:BaseUrl'");
|
?? throw new InvalidOperationException("Missing configuration 'Downstream:Domain:BaseUrl'");
|
||||||
var projectionBaseUrl = builder.Configuration["Downstream:Projection:BaseUrl"]
|
var projectionBaseUrl = builder.Configuration["Downstream:Projection:BaseUrl"]
|
||||||
?? throw new InvalidOperationException("Missing configuration 'Downstream:Projection:BaseUrl'");
|
?? throw new InvalidOperationException("Missing configuration 'Downstream:Projection:BaseUrl'");
|
||||||
|
// The beheer portal's read-only catalogus view reaches the ACL directly (ADR-0025): the catalogus is
|
||||||
|
// not a domain concern, and only the ACL may read the ZGW Catalogi API (§8.1).
|
||||||
|
var aclBaseUrl = builder.Configuration["Downstream:Acl:BaseUrl"]
|
||||||
|
?? throw new InvalidOperationException("Missing configuration 'Downstream:Acl:BaseUrl'");
|
||||||
|
|
||||||
// Validate Keycloak-issued tokens (ADR-0010). Audience validation is off for the walking skeleton —
|
// Validate Keycloak-issued tokens (ADR-0010). Audience validation is off for the walking skeleton —
|
||||||
// Keycloak's audience mapping is a later hardening; signature/issuer/expiry are validated.
|
// Keycloak's audience mapping is a later hardening; signature/issuer/expiry are validated.
|
||||||
@@ -67,14 +71,24 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
builder.Services.AddAuthorization(options =>
|
builder.Services.AddAuthorization(options =>
|
||||||
|
{
|
||||||
options.AddPolicy(BehandelAuth.Policy, policy => policy
|
options.AddPolicy(BehandelAuth.Policy, policy => policy
|
||||||
.AddAuthenticationSchemes(BehandelAuth.Scheme)
|
.AddAuthenticationSchemes(BehandelAuth.Scheme)
|
||||||
.RequireAuthenticatedUser()
|
.RequireAuthenticatedUser()
|
||||||
.RequireRole(BehandelAuth.BehandelaarRole)));
|
.RequireRole(BehandelAuth.BehandelaarRole));
|
||||||
|
// Beheer endpoints reuse the medewerker scheme (same realm, same realm-role lifting) but require the
|
||||||
|
// beheerder role rather than behandelaar (S-15a).
|
||||||
|
options.AddPolicy(BeheerAuth.Policy, policy => policy
|
||||||
|
.AddAuthenticationSchemes(BehandelAuth.Scheme)
|
||||||
|
.RequireAuthenticatedUser()
|
||||||
|
.RequireRole(BeheerAuth.BeheerderRole));
|
||||||
|
});
|
||||||
|
|
||||||
// The BFF is the portals' only backend; it fans out to the domain and projection (§8.3).
|
// The BFF is the portals' only backend; it fans out to the domain and projection (§8.3), and reaches
|
||||||
|
// the ACL for the beheer catalogus read (ADR-0025).
|
||||||
builder.Services.AddHttpClient<IDomainClient, DomainClient>(c => c.BaseAddress = new Uri(domainBaseUrl));
|
builder.Services.AddHttpClient<IDomainClient, DomainClient>(c => c.BaseAddress = new Uri(domainBaseUrl));
|
||||||
builder.Services.AddHttpClient<IProjectionClient, ProjectionClient>(c => c.BaseAddress = new Uri(projectionBaseUrl));
|
builder.Services.AddHttpClient<IProjectionClient, ProjectionClient>(c => c.BaseAddress = new Uri(projectionBaseUrl));
|
||||||
|
builder.Services.AddHttpClient<IAclClient, AclClient>(c => c.BaseAddress = new Uri(aclBaseUrl));
|
||||||
|
|
||||||
builder.Services.AddHealthChecks();
|
builder.Services.AddHealthChecks();
|
||||||
// Clear the auto-populated `servers` block so the committed spec is stable regardless of the host
|
// Clear the auto-populated `servers` block so the committed spec is stable regardless of the host
|
||||||
@@ -205,6 +219,15 @@ app.MapPost("/behandel/registrations/{id}/decide",
|
|||||||
.Produces(StatusCodes.Status401Unauthorized)
|
.Produces(StatusCodes.Status401Unauthorized)
|
||||||
.Produces(StatusCodes.Status403Forbidden);
|
.Produces(StatusCodes.Status403Forbidden);
|
||||||
|
|
||||||
|
// Beheer catalogus viewer (S-15a): the published zaaktypen, read-only. Reached only with a medewerker-
|
||||||
|
// realm token carrying the beheerder role; the BFF proxies the ACL's read (ADR-0025). Public-safe.
|
||||||
|
app.MapGet("/beheer/catalogi/zaaktypen", async (IAclClient acl, CancellationToken ct) =>
|
||||||
|
Results.Ok(await acl.GetZaaktypenAsync(ct)))
|
||||||
|
.RequireAuthorization(BeheerAuth.Policy)
|
||||||
|
.Produces<IReadOnlyList<BeheerZaaktype>>(StatusCodes.Status200OK)
|
||||||
|
.Produces(StatusCodes.Status401Unauthorized)
|
||||||
|
.Produces(StatusCodes.Status403Forbidden);
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|
||||||
/// <summary>The behandelaar's decision on a registration.</summary>
|
/// <summary>The behandelaar's decision on a registration.</summary>
|
||||||
@@ -257,5 +280,13 @@ internal static class BehandelAuth
|
|||||||
private sealed record RealmAccess([property: JsonPropertyName("roles")] string[] Roles);
|
private sealed record RealmAccess([property: JsonPropertyName("roles")] string[] Roles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Beheer (medewerker-realm) authorization wiring (S-15a). Reuses the "medewerker" bearer scheme
|
||||||
|
// (BehandelAuth.Scheme) and its realm-role lifting; only the required role differs.
|
||||||
|
internal static class BeheerAuth
|
||||||
|
{
|
||||||
|
public const string Policy = "beheerder";
|
||||||
|
public const string BeheerderRole = "beheerder";
|
||||||
|
}
|
||||||
|
|
||||||
// Exposed so the test host (WebApplicationFactory<Program>) can boot the app.
|
// Exposed so the test host (WebApplicationFactory<Program>) can boot the app.
|
||||||
public partial class Program;
|
public partial class Program;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
},
|
},
|
||||||
"Downstream": {
|
"Downstream": {
|
||||||
"Domain": { "BaseUrl": "http://localhost:8130/" },
|
"Domain": { "BaseUrl": "http://localhost:8130/" },
|
||||||
"Projection": { "BaseUrl": "http://localhost:8120/" }
|
"Projection": { "BaseUrl": "http://localhost:8120/" },
|
||||||
|
"Acl": { "BaseUrl": "http://localhost:8100/" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -227,10 +227,53 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/beheer/catalogi/zaaktypen": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"Bff.Api"
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/BeheerZaaktype"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"401": {
|
||||||
|
"description": "Unauthorized"
|
||||||
|
},
|
||||||
|
"403": {
|
||||||
|
"description": "Forbidden"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"components": {
|
"components": {
|
||||||
"schemas": {
|
"schemas": {
|
||||||
|
"BeheerZaaktype": {
|
||||||
|
"required": [
|
||||||
|
"identificatie",
|
||||||
|
"omschrijving"
|
||||||
|
],
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"identificatie": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"omschrijving": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"CurrentRegistration": {
|
"CurrentRegistration": {
|
||||||
"required": [
|
"required": [
|
||||||
"registrationId",
|
"registrationId",
|
||||||
@@ -343,4 +386,4 @@
|
|||||||
"name": "Bff.Api"
|
"name": "Bff.Api"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user