The short answer
- Role-based access control (RBAC) gives each user a role, such as Admin or Member, and each role a set of permissions; it is the right starting point for most B2B SaaS products.
- Attribute-based access control (ABAC) decides access from facts about the user, the record and the context, such as a site manager editing only jobs on their own sites, while per-record sharing grants access to one item at a time.
- Check named permissions in code instead of role names, enforce them on the server for every request, and store a user’s role on their membership of a tenant, because these choices are expensive to change later.
Roles and permissions decide who can see and do what inside each customer’s account. A permission is a single allowed action, such as approving an invoice, and a role is a named bundle of permissions given to a user. Most B2B SaaS products should start with role-based access control and a handful of default roles, then add attribute rules, custom roles and per-record sharing as customers ask for them.
Four models of access control
The terms are used loosely, so the table sets them side by side with an example of each.
| Model | How access is decided | Example | Good for |
|---|---|---|---|
| Role-based (RBAC) | The user’s role grants a fixed list of permissions | Members can create quotes, and only Admins can invite users | Almost every product, from day one |
| Attribute-based (ABAC) | Rules combine facts about the user, the record and the context | Managers can approve invoices under £5,000 for their own region | Limits by site, region, amount or status |
| Per-record sharing | Access to one record is granted to one person or group | A client can view their own project and nothing else | Guests, clients and subcontractors |
| Relationship-based (ReBAC) | Access follows links between records, such as team, owner or parent folder | Anyone on a project team can see that project’s documents | Products with nested workspaces and folders |
Mature products usually combine them. Roles set the broad shape of access, attribute rules narrow it, and sharing handles the exceptions.
How role-based access control works
Write permissions as named actions on a resource, such as quotes.create, invoices.approve, users.invite and reports.export. Roles are lists of these permissions. Before every action, the code checks whether this user, in this tenant, has the permission the action needs.
The important rule is to check permissions, never role names. Code that asks whether the user is an Admin has to be found and changed every time roles change. Code that checks invoices.approve keeps working when you add a Finance role or let customers build their own roles.
Default roles to start with
Four or five default roles cover most early customers.
- Owner. Billing, plan changes, deleting the account and transferring ownership. Every account always has at least one.
- Admin. Users, roles, settings and integrations, without billing.
- Member. Day-to-day work, such as creating and editing records.
- Viewer. Read-only access, often for directors or auditors.
- Guest. Access only to specific records shared with them, such as a client viewing their own job.
Products used in the field often need a role shaped around one kind of work. Estimark’s menu includes a field worker mode as well as office screens such as Invoices and Reports. People on site and people who handle money need different things in front of them, and roles are how a product decides who sees which.
When you need attribute rules or per-record sharing
Roles alone can’t express conditions. Requests such as “site managers can only edit jobs on their own sites”, “a submitted timesheet can’t be edited” and “managers can approve spend up to £5,000” all depend on facts about the record or the person. That is attribute-based access control. Implement it as a small set of policy functions that take the user, the record and the action, so the rules live in one place and can be tested.
Per-record sharing is for exceptions to the role. A subcontractor needs to see one job’s drawings. A client needs to approve one quote. Store each share as a row naming the record, the person or group and the access level, and include shares in every query that lists records.
Custom roles
Larger customers eventually ask to define their own roles. If permissions are already named and checked in code, custom roles are mostly an admin screen. Let admins copy a default role and adjust it, describe each permission in plain language, and stop anyone removing the last Owner or their own ability to manage roles. Customers using single sign-on will also want groups from their identity provider mapped to these roles.
Decide what happens when you release a new permission. Default roles get it as you intend. Custom roles should not get it automatically, because a customer who built a careful read-only finance role does not expect it to gain new powers after an update.
How to model roles and permissions in the database
A simple, durable model uses the tables below. The key choice is that the role sits on the membership, the link between a user and a tenant. One person can then be an Admin in their own company’s account and a Guest in a client’s.
| Table | Holds | Notes |
|---|---|---|
| tenants | One row per customer account | Every other business table carries a tenant ID |
| users | People, identified by email or SSO identity | Global, because one person may join several tenants |
| memberships | User ID, tenant ID, role ID and status | The role lives here |
| roles | Name, description and tenant ID | Tenant ID is empty for default roles shared by every tenant |
| role_permissions | Role ID and a permission key | Permission keys are defined in code |
| record_shares | Record type and ID, grantee, access level and expiry | For guests and exceptions |
Keep the list of permission keys in code, under version control, and the assignment of permissions to roles in the database. Cache a user’s permissions for the session, and clear the cache when their role changes.
Mistakes that are expensive to fix later
- Putting the role on the user. It works until the first person needs access to two tenants, and then many queries have to change.
- Checking role names in code. Custom roles become impossible without a rewrite.
- Enforcing permissions only in the interface. Hiding a button is a convenience. The server must check every request, including those to the API.
- Forgetting lists, search, exports and reports. A user blocked from opening a record can often still see it in a CSV export or a dashboard total.
- Missing tenant scoping. Every permission check must also confirm the record belongs to the user’s tenant (multi-tenancy explained).
- Keeping no record of changes. Role changes, new shares and support staff access should all be written to an audit log.
Each of these is cheap to get right in the first version and slow to change once hundreds of screens, queries and reports depend on it.
Questions people ask
What is the difference between a role and a permission?
A permission is one specific allowed action, such as creating a quote or exporting a report. A role is a named group of permissions, such as Admin or Viewer, that you give to a user. Users get their permissions through their role, which keeps access manageable as a team grows.
How many roles should a new SaaS have?
Start with four or five, usually Owner, Admin, Member, Viewer and a guest role for people outside the customer’s company. Fewer roles are easier to explain and to test. Add roles when several customers ask for the same shape of access, and offer custom roles when larger customers need their own.
Do I need a policy engine for permissions?
Most early products don’t. Permission checks in application code, kept in one module and covered by tests, are enough for roles and simple attribute rules. Policy engines and authorisation services such as Open Policy Agent, Cedar or OpenFGA help when rules are complex, shared across several services or need to change without a release.
Should permissions be checked in the front end?
The front end should use permissions to hide or disable actions a user can’t take, which keeps the interface clear. It must never be the only check. Every request to the server has to be checked again, because anyone can call an API directly.