Engineeringarticle9 min read

Authentication vs Authorization: Architecture Patterns for Web Apps

Authentication proves who someone is. Authorization decides what they can do. A clear breakdown of both, common patterns, and how to avoid the mistakes that lead to security incidents.

Written by Bohdan SulymaPublished

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

ConcernAuthenticationAuthorization
Question answeredWho is this?What can they do?
When it runsOnce, at login (plus session validation)On every sensitive request
Common mechanismsPassword + hash, magic link, OAuth/SSO, MFARoles, permissions, ownership checks, policies
Failure modeImpersonation, credential stuffingData 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

  1. 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.

  2. Scope every query by the authenticated session

    Never accept an account, tenant, or owner ID from client input for access control decisions.

  3. 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.

  4. 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

Newsletter

Product notes, not noise.

Occasional frameworks on portals, SaaS MVPs, and automation. No agency spam.

DirectHeader logoDirectHeader

Creating modern, high-performance websites for forward-thinking companies.

Navigation
Contact
[email protected]

Remote Team (EU)

© 2026 DirectHeader. All rights reserved.

Made with precision in EU