Skip to content

Permissions Phase A Built

Permissions governs who can do what, and on which merchant's data. It defines roles, grants permissions to those roles, scopes access per organization/merchant, and automatically filters every list and detail query to the requesting user's reach. Every other module relies on it for authorization.

1. Identity

PropertyValue
Module IDCORE-02
TierCore
StatusBuilt
PhaseP1 (fixed roles + filtering), P2 (custom roles + granular grants)
PriorityHIGH
Primary usersSuper Admin · Admin · Operator · Owner · Cashier · Employee

2. Purpose & Scope

IncludedExcluded
Eight fixed system roles + role hierarchyWildcard permissions (e.g. sales.*)
Custom role creation with priority and scopePermission categories / UI grouping
Permission catalog (create, update, delete)Time- or shift-based permissions
Grant / revoke permissions to rolesPermission audit log
Grant / revoke roles to usersRole templates / pre-configured bundles
Effective-permission query (direct + inherited)Per-merchant active-role switching
Per-merchant & per-organization scoping
Automatic role-based data filtering
Privilege-escalation guard

3. Capabilities

CapabilityWhat the user can doStatus
Fixed system rolesEight immutable roles seeded at startup, each with a numeric priorityBuilt
Role-based data filteringEvery list/count/detail query is auto-filtered to the user's scopeBuilt
System-role bypassSuper Admin, Admin, Operator see all data, skipping scope filteringBuilt
Per-merchant scopingGrants apply within the merchant chosen by the active-merchant headerBuilt
HQ-owner expansionAn Owner at a head-quarter merchant reaches every sibling merchant of that organizerBuilt
Custom rolesCreate roles with an i18n name, priority, and optional org/merchant scopeBuilt
Permission catalogCreate, update, and delete permission definitionsBuilt
Grant / revoke to rolesAdd or remove permissions on a role (idempotent)Built
Grant / revoke roles to usersAssign or remove roles from usersBuilt
Effective permissionsView a user's combined direct + role-inherited permissionsBuilt
Privilege-escalation guardBlock managing any role at or above the actor's own priorityBuilt

4. Module Dependencies

Depends onWhy
User ManagementUsers are the subjects that receive roles and permissions
CommerceOrganizations and merchants are the scopes roles attach to
All feature modulesEvery module's data is filtered and authorized through Permissions

5. Backend Packages

Implementation detail lives in the developer docs — this section only maps the module to the services that power it.

PackageRoleDeveloper docs
@nx/identityRoles, permissions, policy-definition grants, sign-in tokenidentity
@nx/coreCasbin model + per-merchant policy adapter + enforcer wiringCasbin Authorization

6. Key User Flows

7. Roles & Permissions

Live develop snapshot. For the full per-permission breakdown see the Permission Matrix.

RoleIdentifierPriorityEnforcementReach
Super Admin999_super-admin999Always-allow bypassEverything
Admin900_admin900Always-allow bypassEverything
Operator600_operator600Always-allow bypassEverything
Owner500_organizer-owner500Per-merchant domainOwn organizer + its merchants
Cashier110_cashier110Per-merchant domainAssigned merchant (mirrors Employee)
Employee100_employee100Per-merchant domainAssigned merchant
Customer010_customer10None (customer-facing)No backend permissions
Guest001_guest1Global (*)Onboarding-only (pre-merchant)

Owner vs Employee: both receive a lenient full-CRUD grant on most modules and differ only in inventory (Employee is read-only on master data) and ledger (Owner-only). Cashier mirrors Employee exactly.

8. Status & Roadmap

PhaseCapabilities
P1Eight fixed roles · priority hierarchy · system-role bypass · automatic data filtering · role context in sign-in token
P2Custom roles · permission catalog · grant/revoke to roles & users · effective-permission query · privilege-escalation guard · per-merchant scoping
P3 (planned)Wildcard permissions · permission categories · role templates · time-based permissions · permission audit log

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.