Repository navigation
[access] refactor(zgw): share the write gate between the endpoints of the decision and notification APIs - #5874
Merged
Conversation
…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
rubenvdlinde
requested review from
WilcoLouwerse,
bbrands02 and
rjzondervan
as code owners
November 11, 2026 15:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
In
BrcControllerandNrcController,create,update,patchanddestroyeach repeated the JWT check followed by the scope check (besluiten.aanmaken/bijwerken/verwijderenfor the decision API,notificaties.publicerenfor the notification API).Each controller now has one private
writeRefusal()(taking the scope inBrcController, 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 forbesluitinformatieobjectenupdates and its document-link and cascade branches.Same approach as #5865 for the catalogue API.
BrcController::audittrailIndexanddestroyDecision(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.xmlontests/Unit/Controller,ZgwAuthMiddlewareTestandtests/Unit/Architecture: 1,985 tests, all green but two inherited failures.phpcsandphpstan analyseon both controllers: no findings.Inherited:
ServiceCatchReturnsNullTest::testEveryAllowlistEntryNamesALiveSite(a stale allowlist entry forlib/Service/Settings/OpenRegisterBridge.php) andNoteMentionGoldenTest::testGoldenMentionsare red on development too; untouched here.Duplication figures (matching window pairs, before -> after)
BrcController<->NrcController: 48 -> 33NrcController: 34 -> 8BrcController: 26 -> 20What 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