Allow punishment-type reads for roles with punishment permissions - #33
Merged
Conversation
The panel player window fetches punishment types from GET /v1/panel/settings/punishment-types, which was gated behind admin.settings.view.punishments. Moderator-style roles holding only punishment.view / punishment.apply.* got a 403, leaving the window empty even though the create endpoint would have authorized them. Adds PunishmentTypeAccessPolicy: reads permitted for admin.settings.view.punishments, punishment.view, punishment.modify, or any punishment.apply.* permission; writes still require admin.settings.modify.punishments. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
| Row.permission("POST", "/v1/panel/settings/ai-dismiss-suggestion/t1", "admin.settings.modify.punishments"), | ||
| Row.permission("GET", "/v1/panel/settings/punishment-types", "admin.settings.view.punishments"), | ||
| Row.permission("POST", "/v1/panel/settings/punishment-types", "admin.settings.modify.punishments"), | ||
| Row.playerRead("/v1/panel/settings/punishment-types"), |
There was a problem hiding this comment.
Apply-only access remains untested
The new Row.playerRead case grants punishment.view, so it never exercises the hasAnyWithPrefix branch intended for roles holding only punishment.apply.<type>. A regression in that branch would restore the moderator-facing 403 while this authorization matrix continues to pass.
Context Used: Ensure all code meets SOLID, DRY, and KISS softwar... (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/test/java/gg/modl/backend/infrastructure/filter/PanelAuthorizationMatrixTest.java
Line: 101
Comment:
**Apply-only access remains untested**
The new `Row.playerRead` case grants `punishment.view`, so it never exercises the `hasAnyWithPrefix` branch intended for roles holding only `punishment.apply.<type>`. A regression in that branch would restore the moderator-facing 403 while this authorization matrix continues to pass.
**Context Used:** Ensure all code meets SOLID, DRY, and KISS softwar... ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
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.
Problem
The panel player window showed no punishment types for moderator-style roles, making it impossible to apply punishments through the panel. The window fetches types from
GET /v1/panel/settings/punishment-types, which was class-gated behindadmin.settings.view.punishments— a permission the seeded Moderator role (and custom moderation roles) don't hold. The fetch 403'd, so the window had nothing to render, even thoughPunishmentLifecycleService.validatePunishmentPermissionwould have authorized the actual create.The permission strings themselves were consistent on both sides (
punishment.apply.<name>); the read gate was the only break.Fix
PunishmentTypeAccessPolicy: reads permitted foradmin.settings.view.punishments,punishment.view,punishment.modify, or anypunishment.apply.*permission; writes still requireadmin.settings.modify.punishments(mutation behavior unchanged).PanelPunishmentTypeControllernow usesPanelAccessRule.PUNISHMENT_TYPE_ACCESS.PermissionService(reused byPlayerAccessPolicyand the new policy).PanelAuthorizationMatrixTestrow documenting thatpunishment.viewgrants the GET; all pre-existing rows still pass.Testing
compileJava compileTestJavaclean;PanelAuthorizationMatrixTestand role service tests pass.🤖 Generated with Claude Code
Confidence Score: 4/5
Safe to merge functionally, but the new apply-only moderation access path lacks direct regression coverage.
There is one non-security P2 finding. Under the scoring policy, a review containing only P2 findings receives a score of 4.
Files Needing Attention: src/test/java/gg/modl/backend/infrastructure/filter/PanelAuthorizationMatrixTest.java needs a matrix case for a principal with only punishment.apply..
Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "Allow punishment-type reads for roles wi..." | Re-trigger Greptile
Context used: