$auth.roles and $auth.permissions.
Admin only
Choose Users with roleadmin in the rule picker.
Any of several roles
- Has role
editor,admin
By permission
Give roles permissions, then check the permission: Choose Users with permissionposts.write in the rule picker.
with roles such as editor granted posts.write. Add a new role later without touching any rule.
All of several permissions
- Has permission
billing.read,billing.export
Roles or ownership
Admins override ownership:- Any of these rules pass:
- Has role
admin - Owns the record (field)
owner_id
- Has role
Staff with a second factor
Choose All of: Users with rolestaff; Signed in with 2FA in the rule picker.
All entries must pass. A staff member who signed in with just a password is refused until they complete the second step.
A hierarchy
Roles are not ordered by themselves. For “manager or above”, list them:- Has role
manager,director,admin
Read-only role
Aviewer who can list and get but never write:
Roles that depend on the organization
A person may be an admin in one organization and a member in another. Use the organization role, not the global one:- All of these rules pass:
- Compare values:
$record.orgequals$auth.org - Compare values:
$auth.org_roleis one ofadmin, owner
- Compare values:
Service-only operations
For things only your servers do: Choose Secret keys & Studio in the rule picker. Reads and writes then work only with a secret key. Offer users what they need through a route.Show UI by role, protect by rule
When roles change
A new role arrives with the next token refresh (minutes) or the next sign-in; end sessions to force it (Roles).Roles in Auth
Define and assign.
Sensitive actions
Add a second factor.