Functional contract
RBAC
Who may do what, and where. The role and action catalog is global, owned by SuperUsers. Organization, Location group, and Location administrators only assign or revoke those roles on Staff.
Catalog vs assignment
| Layer | Who | What |
|---|---|---|
| Catalog | SuperUser at /admin/roles and /admin/actions | CRUD roles, CRUD actions, attach/detach actions on a role |
| Assignment | Organization, Location group, and Location administrators at /app/settings?tab=users (GET /app/staffs redirects) | Assign or revoke catalog roles on Staff |
| Invite | Organization administrator at the same tab (POST /app/staffs) | Create a pending Staff (and a User when the email is new). Resend or withdraw pending invites. Disable/enable memberships without changing the User |
Tenants never mutate the catalog. SuperUsers are gated by session, not by a tenant action key. Impersonation from /admin/users uses the target User's Staff RBAC; it grants no elevated rights.
Model
| Role scope | Target | Applies at |
|---|---|---|
organization | location_id nil | Every Location in the Organization |
location | A Location in the Organization | That Location only |
location_group | A Location Group (location_group_id, Elite only) | Every Location currently in the group, including ones added later |
- Only group-scoped roles may target a group, and they may not target a Location. An assignment targets one scope (check constraint); the same role cannot repeat in the same scope.
- Group roles may hold location and “both” actions (applied at member Locations) plus
location_groupactions; never organization actions. Location roles cannot holdlocation_groupactions. StaffRoleAssignment#covers_location?is the single rule (org-wide, same Location, or the Location's group).granted_locations,works_at?,allowed_to?,Staff.bookable_at, and the schedule picker follow it.- No group workspace; group roles surface as member Locations in the switcher.
- Staff may hold several assignments. System roles and actions cannot be destroyed.
organization_administratoralways keepsstaff.roles.assign.
Rbac.sync! (Rbac::Catalog) seeds the catalog. Organization.provision! assigns the founder org-wide Organization administrator.
Who may assign
| Actor | May |
|---|---|
| SuperUser | Mutate the catalog only. Not clinic staff |
| Organization administrator | Any role on any Staff (org-wide, any group, any Location). Invite, resend, withdraw, disable/enable. Cannot open /admin |
| Location group administrator | Location-scoped roles at every Location of their group, and the Location group administrator role on that group. No org-scoped roles or other groups. Cannot invite, resend, withdraw, or disable |
| Location administrator | Location-scoped roles only, at Locations they admin. Cannot invite, resend, withdraw, or disable |
| Everyone else | No assignment UI |
The last Organization administrator assignment in an Organization cannot be removed.
Action keys
| Scope | Actions |
|---|---|
| Organization | organization.manage, catalog.manage (master items, pricing groups, patient groups, locks), appointmenttypes.manage, taxes.manage (taxes and tax groups), reports.organization, commissiongroups.manage |
| Both | staff.roles.assign, catalog.read, appointmenttypes.read, taxes.read, locations.read, reports.read, settings.manage |
| Location group | locationgroups.manage: group profile (name, code, description); group catalog, price, patient group, and tax overrides and locks; exclusive-item grants; group-owned patient groups, taxes, tax groups, and commission groups (including staff on those commission groups). Membership stays with organization.manage |
| Location | catalog.override (unlocked item, price, and patient group overrides), appointmenttypes.override, taxes.override, locations.manage, patients.*, appointments.*, visits.*, soap.manage, inventory.*, billing.*, checkout.*, invoices.*, payments.*, tips.*, commissions.* (each .read / .manage) |
Clinic invoices use invoices.*; SaaS Settings billing keeps billing.*. Tips: Clinic tips. Commissions: Commissions.
Default roles
| Role | Scope | Grants |
|---|---|---|
| Organization administrator | Organization | All tenant actions, including staff.roles.assign |
| Location group administrator | Location group | Every Location administrator action at each member Location, plus locationgroups.manage. Settings pages filter to their groups |
| Location administrator | Location | Site operations, staff.roles.assign (location-scoped only), catalog.read / catalog.override, appointmenttypes.read / .override, taxes.read / taxes.override, soap.manage, checkout.*, invoices.*, payments.*, tips.*, commissions.* |
| Receptionist | Location | Appointments, appointmenttypes.read, taxes.read, visits, patients.*, billing, checkout.*, invoices.*, payments.*, tips.read, commissions.read, reports.read |
| Veterinarian | Location | patients.*, appointments.read, appointmenttypes.read, taxes.read, visits.*, soap.manage, catalog.read, inventory.read, checkout.read, invoices.read, payments.read |
Authorization helpers
| Area | Helpers |
|---|---|
| Core | allowed_to?(key) (no location = org-wide only), allowed_to?(key, location:), granted_locations |
| Schedule / whiteboard | may_read_appointments_at? / may_manage_appointments_at?; may_read_visits_at? / may_manage_visits_at?; sidebar uses the non-_at variants |
| Patients, diagnostics | may_read_patients? / may_manage_patients?; diagnostic orders reuse soap.manage and patients.read |
| Catalog | may_read_catalog?, may_manage_catalog?, may_override_catalog_at?; Catalog::ItemPolicy (items, grants, locks), Catalog::PricingPolicy (prices, patient groups) |
| Taxes | may_read_taxes?, may_manage_taxes?, may_override_taxes_at? |
| Location groups | may_manage_location_group?; group-owned records use may_manage_owned? (org permission, or locationgroups.manage on the owner) |
| Commissions | may_manage_commission_groups? |
| Inventory, checkout, invoices, tips | may_read_*_at? / may_manage_*_at?; sidebar links use may_read_*? |
| Settings | can_view_settings?; Users & Roles uses can_assign_roles? and may_assign? |
Acceptance
- Founder
/registercreates an org-wide Organization administrator who can open every Location. - A veterinarian assigned only at A is allowed at A, not B, and cannot open
/app/settingsor/app/staffs. - A Location administrator cannot assign Organization administrator or assign at a Location they do not admin.
- A Location group administrator operates every Location in the group, including ones added later, and loses a Location when it leaves the group.
- SuperUser can CRUD roles and actions at
/admin; staff hitting those routes are redirected to/app. - Impersonation uses the target User's Staff RBAC only.
- Pending Staff cannot act until accepted. The last Organization administrator cannot be revoked. System roles and actions cannot be deleted.
Access rules: Staff access. Out of scope: role hierarchy, invite email, SSO, seat caps, SuperUser elevated workspace.