Roles and permissions
Name permissions in code, map roles to them in one place, and test every role against every action. Then access stays right as the product grows.
- Required 6
- Recommended 2
Required
Check a named permission on the server for every action
ACC-34Check on the server, for every action, whether the user has a named permission such as
invoice.refund. Map roles to permissions in one place, and never compare role names in feature code. Hiding a button is not a check.Check ownership on every record
ACC-77Before returning or changing a record, check on the server that it belongs to the logged-in user or their team.
Test every role and a signed-out visitor against every action
ACC-36Keep a table of every role and every action with the expected answer, and run it as a test against the server on every change.
Give roles inside an organisation
ACC-37Store customer roles on the membership between a user and an organisation. Keep staff roles in a separate store that customer code cannot write.
Apply removed roles within the revocation limit
ACC-38Apply a removed role or permission within the limit in end sessions when access changes. Never keep roles only inside a long-lived token or cache.
Limit tokens and agents to what their owner may do
ACC-39Give an API key, connected app or AI agent at most its creator's permissions. Check the creator's current role on every call.
Recommended
Start with roles and add record rules only when needed
ACC-35Start with a few roles per organisation. Add conditions on the record only for rules that need them, such as "only the author may edit a draft".
Let owners see who can do what
ACC-40Give organisation owners one page that lists every member, role, sign-in method and last activity, with pending invitations, API keys and an export.
Read this with
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/accounts/roles-and-permissions">Agent Wranglers accounts and identity playbook</a>. In code you write, add a comment next to it with the same link.