Every serious web application needs to answer two questions on every request: who is this, and what are they allowed to do? The first is authentication. The second is authorization, and for most business software the practical way to manage it is role-based access control. Get both right early and you avoid data leaks, awkward rewrites and enterprise deals stalled by security reviews.
Authentication options and when to use them
Think about who signs in, how often and from where. Field staff on shared tablets, enterprise employees behind corporate identity providers and consumers signing up on a phone all need different flows. Many products end up supporting two or three methods, which is fine as long as they all lead to the same account model underneath.
There is no single best login method. Pick based on your users and your market.
| Method | Best for | Things to consider |
|---|---|---|
| Email and password | General audiences who expect it | Needs secure hashing, reset flows and protection against brute-force attempts |
| Magic links or one-time codes | Infrequent users, low-friction sign-in | Depends on email deliverability; links must expire quickly |
| Social login (OAuth) | Consumer apps and quick sign-up | Plan for users who lose access to the provider account |
| Enterprise SSO (SAML or OIDC) | B2B products selling to larger companies | Often a requirement in procurement; needs per-customer configuration |
| Passkeys | Modern apps wanting phishing-resistant login | Offer alongside a fallback during adoption |
Whatever you choose, add two-factor authentication, at least as an option and ideally required for admins. Authenticator app codes are a sensible default. Do not build cryptography or session handling from scratch; use a proven auth provider or a well-maintained library. Managed backends often include auth out of the box, as we discuss in Supabase vs Firebase for startups.
How role-based access control works
RBAC groups permissions into roles and assigns roles to users. Instead of granting each person dozens of individual rights, you say Maria is an Editor, and Editors can create and update content but not delete it or manage billing.
The model has three pieces:
- Permissions: specific actions on specific resources, such as product.update or invoice.view.
- Roles: named bundles of permissions that match real job functions.
- Assignments: which users hold which roles, and in multi-tenant apps, in which organization.
An example role matrix
Here is a simple matrix for a content-focused B2B tool. Your roles will differ, but the format is worth copying.
| Permission | Owner | Admin | Editor | Viewer |
|---|---|---|---|---|
| View content | Yes | Yes | Yes | Yes |
| Create and edit content | Yes | Yes | Yes | No |
| Delete content | Yes | Yes | No | No |
| Invite and remove users | Yes | Yes | No | No |
| Manage billing | Yes | No | No | No |
| Delete organization | Yes | No | No | No |
Writing a matrix like this before coding forces useful conversations and becomes living documentation for your team and your customers.
Roles in multi-tenant applications
In B2B software, a user’s role usually depends on the organization they are acting in. The same person may be an Admin in one workspace and a Viewer in another. Store roles on the membership that links a user to an organization, not on the user record itself. Always resolve the current organization on the server from the session, and check that the user actually belongs to it. Our Sanctus platform uses this approach, combining per-brand roles with two-factor authentication for team members.
Enforce permissions in the right places
Hiding a button is a convenience, not a security control. Enforce access in layers:
- Server or API layer. Every endpoint checks the caller’s permission for the specific resource before acting.
- Database layer. Where possible, use database rules such as PostgreSQL row-level security as a second line of defense.
- Interface layer. Hide or disable actions the user cannot perform, so the experience matches their rights.
- Background jobs and webhooks. These often bypass normal request paths, so check them explicitly too.
When roles are not enough
Pure RBAC struggles with rules like editors can only edit posts in their own department, or managers can approve expenses below a certain amount. Those depend on attributes of the user, the resource or the context. You can handle them with a few targeted ownership or attribute checks layered on top of roles, or with a fuller attribute-based or relationship-based model if the rules are central to your product. Start simple and add complexity only when real requirements demand it.
Common pitfalls to avoid
Most access control bugs are not exotic attacks. They are ordinary oversights that slip through because nobody wrote down the rules. Watch for these in particular:
- Checking roles by name throughout the code instead of checking permissions, which makes adding a role painful.
- Trusting user IDs or organization IDs sent from the browser.
- Forgetting to invalidate sessions when a user is removed or their role changes.
- No audit trail for permission changes.
- Letting the last owner leave or demote themselves, locking everyone out.
- Allowing custom roles before you have a clear set of permissions underneath them.
How SiteWright Technologies approaches access control
SiteWright Technologies builds authentication, two-factor login and role-based permissions into web apps from the start, with enforcement at both the API and database levels. If you are planning a new product or tightening an existing one, explore our full-stack development services or get in touch.


