Skip to content

Hold staff to their permissions and store limits on direct requests (owner review required) - #669

Merged
techmore merged 2 commits into
mainfrom
claude/staff-store-scope-authz
Nov 19, 2026
Merged

techmore merged 2 commits into
mainfrom
claude/staff-store-scope-authz

Conversation

@techmore

Copy link
Copy Markdown
Owner

Owner review required before merge. This changes authorization code, and main deploys to production. Nothing here was merged or deployed.

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

# Who Before After
1 Roles with inventory.read only (cashier, reader, reporting) Could open the bulk material use form and reach its create action. The subclass redeclared authorize_inventory_write for preview only, which replaced the parent's check on new/create. A preview token made while someone had inventory.write still recorded a stock deduction after the permission was removed. new, preview and create all need inventory.write.
2 Manager limited to some stores Could approve, deny or cancel time off for another store's staff by URL. LeaveRequestPolicy had the store rule but the controller never asked it. Refused in the controller with a plain message, and in LeaveRequestWorkflow.
3 Manager limited to some stores Could read, edit, add hours to and delete another store's timesheet by URL (only approve? checked the store). TimesheetPolicy#show?/update?/reopen? apply the same store rule as approve?. A person's own timesheet is unaffected.
4 Manager limited to some stores Could add, change, move or remove shifts for another store or its staff. Refused, on the shift as it is and as it would be saved.
5 Anyone with schedule access but not payroll.read (manager by default) The schedule grid printed each person's hourly rate, which the staff profile and punch history hide without payroll.read. The rate shows only with payroll.read.
6 A POS user not on an event's staff list The event register returned the event's items, prices and the list of managers who approve overrides (selling was already refused). They get the existing "not on this event's staff list, ask the event manager" page with no items or approvers.

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)

  • Labor cost on the schedule. Item 5 hides the per-person rate only. The week's labor cost and labor % tiles still show to schedulers without payroll.read, because the schedule builder is built around them; with one person on a day, a rate can be worked out from them.
  • Lists. A store-limited manager still sees other stores' rows on the time-off list, the time-keeping staff view and the schedule grid. They can no longer act on 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 the app/ 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 failures
  • bin/rails test (whole suite): 4073 runs, 55019 assertions, 0 failures, 0 errors, 5 skips
  • bin/rubocop on the changed files: no offenses

🤖 Generated with Claude Code

techmore and others added 2 commits November 18, 2026 20:24
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>
@techmore
techmore merged commit d027aa9 into main Nov 19, 2026
8 checks passed
@techmore
techmore deleted the claude/staff-store-scope-authz branch November 19, 2026 13:04
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.

1 participant