Skip to content

[access] refactor(zgw): share the write gate between the endpoints of the decision and notification APIs - #5874

Merged
rubenvdlinde merged 2 commits into
developmentfrom
quality/h16-brc-nrc-write-gate
Nov 12, 2026
Merged

rubenvdlinde merged 2 commits into
developmentfrom
quality/h16-brc-nrc-write-gate

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

What changed

In BrcController and NrcController, create, update, patch and destroy each repeated the JWT check followed by the scope check (besluiten.aanmaken / bijwerken / verwijderen for the decision API, notificaties.publiceren for the notification API).

Each controller now has one private writeRefusal() (taking the scope in BrcController, whose writes need different ones): the JWT refusal as it was, else the same 403 permission body, else null. Every write calls it first, so both checks still run, in the same order, before anything is read or written. The rest of each method is unchanged, including the decision API's 405 for besluitinformatieobjecten updates and its document-link and cascade branches.

Same approach as #5865 for the catalogue API. BrcController::audittrailIndex and destroyDecision (changed by #5340 and #5349) are not touched.

The title carries the access prefix because the JWT and scope checks move into the private gates. Allowed and refused outcomes are unchanged, as the golden below pins.

Characterisation tests

tests/Unit/Controller/BrcNrcWriteGateGoldenTest.php, committed first and green on the old code: for each of the eight writes, a JWT refusal is answered as is and the scope is never asked; a consumer without the scope gets the exact 403 body and the store is never reached; an allowed write reaches the store once with the exact arguments and its answer passes through. 24 cases.

Mutation check: in each controller, turning the scope test around in writeRefusal() made 8 cases red, and dropping its JWT refusal made 4 red. Restored, all green.

What ran

  • phpunit -c phpunit-unit.xml on tests/Unit/Controller, ZgwAuthMiddlewareTest and tests/Unit/Architecture: 1,985 tests, all green but two inherited failures.
  • phpcs and phpstan analyse on both controllers: no findings.

Inherited: ServiceCatchReturnsNullTest::testEveryAllowlistEntryNamesALiveSite (a stale allowlist entry for lib/Service/Settings/OpenRegisterBridge.php) and NoteMentionGoldenTest::testGoldenMentions are red on development too; untouched here.

Duplication figures (matching window pairs, before -> after)

  • BrcController <-> NrcController: 48 -> 33
  • inside NrcController: 34 -> 8
  • inside BrcController: 26 -> 20

What remains between them is the endpoints that only check the JWT and hand over to the store (show, audittrailShow, the store calls themselves), which have the same shape in every ZGW controller.

AI-assisted: prepared with Claude Code (claude-opus-5-5); reviewed by a maintainer before merge.


Generated by Claude Code

…s before sharing their gates

Assisted-by: ClaudeCode:claude-opus-5-5
…sion and notification APIs

Create, update, patch and destroy in BrcController and NrcController each
repeated the JWT check followed by the scope check. Each controller now has
one private writeRefusal(), called first by every write, so both checks
still run in the same order before anything is read or written.

Assisted-by: ClaudeCode:claude-opus-5-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants