This repository was archived by the owner on May 29, 2026. It is now read-only.
fix: harden auth guards on agenda/motion/voting endpoints#343
Merged
Conversation
Bugs fixed: - AgendaController publish/advanceBobPhase/processHamerstukken/reorder/revise: add explicit `getUser() === null → 401` as the FIRST statement in each method so unauthenticated requests return 401 before any service or CSRF middleware interaction can produce an incorrect 500 or 422. advanceBobPhase specifically now guards before the objectService->find() call that previously ran without authentication. - MotionController + VotingController: add missing #[NoAdminRequired] PHP 8 attribute to all action methods (only @NoAdminRequired docblock existed). Without the attribute, NC 28+ SecurityMiddleware treats the endpoint as admin-only and blocks non-admin authenticated users. Also fixes the requireChairOrSecretary() helper in both controllers to return 401 (not 403) when getUser() is null — unauthenticated is different from authenticated-but-unauthorised. Bug 4 (motion-voting routes): routes ARE registered in appinfo/routes.php and controller methods DO exist. The 405 responses Newman observed were caused by the missing #[NoAdminRequired] attribute; fixed above. Adds unit tests asserting: - every affected endpoint returns 401 (not 403/422/500) for null user - service methods are never called for unauthenticated requests - MotionController and VotingController action methods carry #[NoAdminRequired]
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
Fixes four Newman-discovered backend auth bugs:
getUser() === null → 401as the first statement inprocessHamerstukken()andreorder()(and all other AgendaController state-changing methods) so unauthenticated requests short-circuit before any service or middleware interaction.advanceBobPhase()was callingobjectService->find()before the auth check. AddedgetUser() === null → 401as the very first line so the auth gate runs before any object lookup.publish().MotionControllerandVotingControlleraction methods had@NoAdminRequiredin docblock only, missing the PHP 8#[NoAdminRequired]attribute. Without the attribute, NC 28+ SecurityMiddleware treats endpoints as admin-only. Routes and controller methods were already present. Also fixedrequireChairOrSecretary()to return 401 (not 403) for null user.Changes
lib/Controller/AgendaController.php— explicitgetUser() === null → 401at top of all 5 action methodslib/Controller/MotionController.php— add#[NoAdminRequired]to 6 methods; fix null → 401lib/Controller/VotingController.php— add#[NoAdminRequired]to 7 methods; fix null → 401AgendaControllerTest,MotionControllerTest,VotingControllerTestTest plan
composer check:strict→ ALL CHECKS PASSED (196 tests, 998 assertions, 0 failures)