These two get conflated constantly, and the conflation is where security bugs live. A user being logged in (authenticated) says nothing about which records, actions, or accounts they should be able to touch (authorization).
Where each one happens
| Concern | Authentication | Authorization |
|---|---|---|
| Question answered | Who is this? | What can they do? |
| When it runs | Once, at login (plus session validation) | On every sensitive request |
| Common mechanisms | Password + hash, magic link, OAuth/SSO, MFA | Roles, permissions, ownership checks, policies |
| Failure mode | Impersonation, credential stuffing | Data leaks across accounts, privilege escalation |
Common authentication patterns
- Password + secure hashing — still standard, requires proper hashing (bcrypt/argon2), rate limiting, and breach-aware validation
- Magic links / one-time codes — removes password management, good fit for low-friction B2B and portal logins
- OAuth / SSO — delegates identity to a trusted provider (Google, Microsoft, an enterprise IdP); reduces password sprawl for B2B software
- Multi-factor authentication (MFA) — an added factor beyond something you know; standard for admin and financial access
Common authorization patterns
- Role-based access control (RBAC) — permissions attached to roles, roles attached to users; scales well for internal tools and B2B products
- Attribute-based access control (ABAC) — permissions computed from attributes (department, region, project) rather than fixed roles; more flexible, more complex
- Ownership-based checks — a user can act on a resource only if they own it or belong to its account; the default pattern for client portals and multi-tenant SaaS
// Wrong: trusts an ID supplied by the client
async function getInvoice(invoiceId: string, accountId: string) {
return db.invoice.findFirst({ where: { id: invoiceId, accountId } });
}
// Right: derives the account from the authenticated session
async function getInvoice(invoiceId: string, session: Session) {
return db.invoice.findFirst({
where: { id: invoiceId, accountId: session.accountId },
});
}
A practical checklist
Separate the two concerns in code
Authentication middleware confirms identity and attaches a session. Authorization checks run explicitly per resource, never assumed from a role alone.
Scope every query by the authenticated session
Never accept an account, tenant, or owner ID from client input for access control decisions.
Choose RBAC first, add ABAC only when roles stop fitting
Most products never outgrow roles. Attribute-based rules add real complexity; earn it before adding it.
Log authorization failures
Repeated authorization failures from one account are a signal worth alerting on, not silently ignoring.
FAQ
FAQ
What is the difference between authentication and authorization?+
Authentication verifies identity: confirming a user is who they claim to be, typically via password, magic link, or SSO. Authorization happens after that and determines what an authenticated user is allowed to see or do.
Can you have authorization without authentication?+
Not meaningfully. Authorization decisions depend on knowing who is making a request. Without authentication, a system can only apply the same public-level access to everyone.
What is role-based access control (RBAC)?+
RBAC is an authorization model that assigns permissions to roles (admin, editor, viewer) rather than individual users, then assigns users to roles. It scales better than per-user permissions as a team or customer base grows.
Related resources
Technical Debt: How to Identify, Measure, and Pay It Down
A practical definition of technical debt, how to tell deliberate trade-offs from accidental decay, and a repeatable process for paying it down without stopping feature work.
EngineeringWebsite Architecture Explained: Layers, Patterns, and How to Choose One
What website architecture actually means, the layers involved, the main patterns in use today, and a practical framework for picking one based on real constraints.
EngineeringWhat Is a Client Portal? Definition, Architecture, and When You Need One
A clear definition of client portals, how they differ from websites and SaaS products, and the architecture decisions that matter for secure B2B delivery.
Newsletter
Product notes, not noise.
Occasional frameworks on portals, SaaS MVPs, and automation. No agency spam.