Skip to content

feat(authz): permission grant tables + can(), unused (#804 step 2) - #806

Open
mbhewitt wants to merge 4 commits into
mainfrom
feat/permissions-tables
Open

mbhewitt wants to merge 4 commits into
mainfrom
feat/permissions-tables

Conversation

@mbhewitt

@mbhewitt mbhewitt commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

#804 step 2: permission grant tables + can() (unused)

Adds the tables and the single server-side check. No route calls can() yet (that's step 3), so merging changes nothing.

Model (agreed in #census 2026-10-18)

One row = one grant. A row is who × permission × scope × window × place. Grants only allow: any matching row lets the action through, so row order never matters. Later, App Admin edits these rows from a screen (Mew).

field values
who anyone (signed out too), signed_in, role, position
scope everyone, self (the subject is the actor), shift (actor and subject are on the shift being acted on)
window op_time_window: shift-anchored start/end ± minutes; NULL = open
place any, on_playa, off_playa
  • Position grants only count on the shift being acted on. Leading Monday's Gate Sampling shift gives no control over Tuesday's (Mew: a lead controls the shift they're on).
  • Not included yet: department scope (VC per-department is a "might") and event-date windows. These get added when a grant needs them.

Permission catalog

client/src/lib/permissions.logic.ts. Added in this PR:

  • shift_volunteers:add_override: ignore full slots and required role
  • volunteer_notes:view
  • volunteer_passcode:reset

Seed = today's behavior exactly

  • SuperAdmin (role 1) only: shift setup, roles, superadmin role, SAPs, QR codes, printing, tablets.
  • Admin or SuperAdmin:
    • role members, volunteer list, volunteer records, bounced email
    • shift volunteers: add / remove / check-in / review
    • add_override, notes view, passcode reset
  • Signed in:
    • own record and own passcode
    • add self; add anyone on-playa
    • drop self until 24h after shift end
    • check-in and review on-playa
  • Signed out: walk-up check-in on-playa, ±30 min around shift start. The route still requires the device cookie.

No lead, Scheduler, VC or Volunteer Assistant grants are seeded. Those get configured in step 4.

Tested

  • node --import tsx --test tests/unit/permissions.test.ts: 6/6
  • tsc --noEmit is clean.
  • Migration applied on MariaDB 11.8 (prod's version) with tz tables.
  • can() was run end-to-end against fixtures: 14/14 scenarios:
    • admin vs volunteer override
    • self / other / admin passcode reset
    • lead sees notes only for people on their shift, and not on a shift they don't lead
    • a non-lead on the shift is refused
    • guest walk-up inside the window passes; future shift or no shift is refused
    • self-drop needs a shift

Next

  1. Step 3: move routes onto can() one group at a time, with parity tests.
  2. App Admin grants screen. Roles are listed first, then positions, clearly labeled (Chipper).
  3. Step 4: configure Scheduler / VC / Volunteer Assistant / Lead.

Footer 2026.F.00806.C. This conflicts with #805 on the Footer, so rebase whichever merges second. Migration 021; #808 uses 022.

🤖 Generated with Claude Code

op_role_grant / op_time_window / op_position_auto_role, seeded to
reproduce today's server checks (SuperAdmin, Admin, own-record, the
on-playa + walk-up rules). can() in lib/permissions.ts; pure matching in
permissions.logic.ts with unit tests. No route calls it yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mbhewitt and others added 2 commits October 18, 2026 00:00
…nt (#806)

Per Chipper: auto-role on position assignment doesn't touch permissions;
it gets its own issue. Rename avoids confusion with the existing
op_role_grant_roster (roles-on-login).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mew: lead access comes from the lead position held; who may be assigned
to a lead position is a separate question (#807). Role grants stay for
VCs / area roles. Both grantee types live side by side.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep role/position/signed_in/anyone grantees and everyone/self/shift scope.
Drop department scope and event-date windows. A position now only counts on
the shift being acted on, and 'shift' scope requires the subject on the shift
too. Add add_override, volunteer_notes:view and volunteer_passcode:reset,
seeded to today's behavior.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mbhewitt

Copy link
Copy Markdown
Owner Author

Mew (2026-11-27): hold until after the permissions meeting.

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