- System roles (
UserRoleenum) — stored in theusers.rolecolumn. Controls access to the Filament admin panel and super-admin features. - Tenant roles (
Roleenum + Spatie Permission) — scoped to a tenant membership. Controls what actions a staff member can perform within a business.
System roles
Defined inApp\Domain\Identity\Enums\UserRole:
The
super_admin role can also be granted by listing an email in the APP_SUPER_ADMINS environment variable (comma-separated). This takes precedence over the database role column.Tenant roles and permissions
Tenant-scoped roles are managed by Spatie Laravel Permission and defined inApp\Domain\Access\Enums\Role:
Permission list
Permissions are defined inApp\Domain\Access\Enums\Permission and assigned to roles in config/rbac.php:
Full permission list
Full permission list
Role presets
config/rbac.php defines presets for common staff roles tied to a plan capability:
Checking permissions in code
In PHP (Spatie)
Checking system role
In Filament resources
Filament resources respect Laravel’s Gate. UsecanAccess or canViewAny methods that delegate to the registered Policy:
Tenant ownership middleware
Thetenant.ownership middleware (EnsureTenantOwnership) is applied to all protected tenant API routes:
tenant_id belongs to one of the authenticated user’s tenants. On a mismatch:
- A
TENANT_OWNERSHIP_VIOLATIONevent is logged to thesecuritylog channel. - The request is aborted with
404(not403) to avoid disclosing resource existence.
Product, Order, Coupon, MenuSection, Lead, Campaign.
Impersonation
Super-admins can impersonate tenant users directly from the Filament admin panel. The original admin session is preserved inimpersonator_id and impersonator_name session keys.
Leaving impersonation
ImpersonationController::leave method:
- Verifies that an active impersonation session exists (
impersonator_idin session). - Logs the
impersonation_endedevent with the original admin ID, impersonated user ID, IP, and user agent. - Clears the impersonation session keys.
- Logs out the impersonated user and restores the original admin session.
- Regenerates the session ID to prevent session fixation.