Repository navigation
Hold staff to their permissions and store limits on direct requests (owner review required) - #669
Merged
Merged
Conversation
Six places where a staff role could do by direct request what its permissions or store limits do not allow. Found in an audit of the staff experience; each has a request test that fails before the change and shows the owner still allowed. - Bulk material use: new and create need inventory.write again. The subclass redeclared the parent's callback for preview only, which replaced the parent's new/create check. - Time off: a manager limited to some stores can no longer approve, deny or cancel a request for another store's staff by its URL. Enforced in the controller and in LeaveRequestWorkflow. - Timesheets: the same manager can no longer read, edit, add hours to or delete another store's timesheet (TimesheetPolicy show/update/reopen). - Schedule: the same manager can no longer add, change, move or remove shifts for another store or its staff. - Schedule: each person's hourly rate shows only with payroll.read, as on the staff profile and punch history. - Event register: someone not on the event's staff list no longer receives the event's items, prices and the list of override approvers. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
Found while auditing what non-owner staff can do. Six places where a staff role could do by direct request (a typed URL or a hand-made form post) what its permissions or store limits do not allow. Nothing here lets staff reach settings, user management, payment configuration or another workspace; the audit found those sound.
What changes
inventory.readonly (cashier, reader, reporting)authorize_inventory_writeforpreviewonly, which replaced the parent's check onnew/create. A preview token made while someone hadinventory.writestill recorded a stock deduction after the permission was removed.new,previewandcreateall needinventory.write.LeaveRequestPolicyhad the store rule but the controller never asked it.LeaveRequestWorkflow.approve?checked the store).TimesheetPolicy#show?/update?/reopen?apply the same store rule asapprove?. A person's own timesheet is unaffected.payroll.read(manager by default)payroll.read.payroll.read.Items 2 to 4 only affect managers who have store limits set (
User#location_ids). A manager with no limits, and every admin, behaves as before.For the owner to decide (not changed here)
payroll.read, because the schedule builder is built around them; with one person on a day, a rate can be worked out from them.Tests
web/test/integration/staff_authorization_gaps_test.rb: 7 tests, 103 assertions. Each case shows the staff role refused and the owner (admin) still allowed; one shows a store-limited manager still deciding for their own store. With theapp/changes stashed, 6 of the 7 fail (the seventh is that positive control).Run locally on macOS, Ruby 4.0.9, SQLite:
bin/rails test test/integration/staff_authorization_gaps_test.rb: 7 runs, 0 failuresbin/rails test(whole suite): 4073 runs, 55019 assertions, 0 failures, 0 errors, 5 skipsbin/rubocopon the changed files: no offenses🤖 Generated with Claude Code