RadarTrek
Home/Courses/Auth Patterns Deep Dive
🔐Intermediate8 lessons · 2 free

Auth Patterns Deep Dive

Authentication is the most common source of security bugs in SaaS products. Not because auth is hard — but because most tutorials teach the basics and skip the edge cases. This course covers how auth actually works under the hood, the session vs JWT tradeoff, OAuth flows in depth, magic links, multi-tenancy auth, row-level permissions, and the 12 auth mistakes that get products breached.

Prerequisites: Some programming experience
Start free lessons
$69one-time · lifetime access

What you'll learn

Identity, authentication, and authorisation — the three primitives every auth system is built from
Sessions done right — httpOnly, Secure, SameSite, session fixation, expiry, and invalidation
JWTs: the full picture — structure, RS256 vs HS256, the algorithm confusion vulnerability, and when not to use JWTs
OAuth flows in depth — Authorization Code + PKCE, state parameter, and building "Sign in with GitHub"
Magic links and passwordless auth — secure token generation, hashing, single-use enforcement, and Resend integration
Multi-tenant auth — organisations, invitations, RBAC roles, and the org_id on every query pattern
Protecting routes and API endpoints — IDOR prevention, middleware-based protection in Next.js
The auth security checklist — the 12 mistakes that get products breached, and exactly how to fix each one

Course outline

Full course — $69 one-time

03

JWT: The Full Picture

Structure, claims, signing algorithms, expiry, verification failures, and the attacks libraries miss

12 min
04

OAuth Flows In Depth

Authorization Code + PKCE, state parameter, callback URL pitfalls, account linking, and error handling

13 min
05

Magic Links and Passwordless Auth

Token generation, hashing, single-use enforcement, expiry, and the failure cases most apps do not handle

11 min
06

Multi-Tenant Auth

Organisations, the invitation flow, tenant isolation on every query, and RLS with org context

13 min
07

Protecting Routes and API Endpoints

RBAC in middleware and route handlers, IDOR prevention, and why 404 beats 403 for security

11 min
08

The Auth Security Audit

Eight checks, eight insecure-vs-secure code pairs, one audit to run before you ship

14 min

Get the full course

8 lessons — from sessions and JWTs to OAuth, magic links, multi-tenant RBAC, and the security checklist.

8 lessons✓ Security-first patterns✓ Certificate
$69one-time

About this course

Authentication and authorisation are the most security-critical parts of any web application. Getting them wrong means user accounts get compromised, data gets exposed, and businesses face regulatory consequences. Learning auth patterns means understanding the full authentication lifecycle, how to implement login with password, magic link, OAuth, and passkeys, how sessions and JWTs work under the hood, and how to implement role-based access control that is simple and maintainable.

This course is for full-stack and backend developers who want to understand what their auth library is doing and why, make informed decisions about auth architecture, and implement custom auth where libraries fall short. After completing it you will be able to implement secure authentication from scratch, configure Supabase Auth correctly, implement RBAC with row-level security, and audit an existing auth implementation for common mistakes.

Frequently asked questions

Should I build auth myself or use a library?

Use an established auth library or service (Supabase Auth, Auth.js, Clerk) unless you have specific requirements they cannot meet. Auth involves a long list of security-critical details — secure session management, token rotation, brute force protection, password storage, CSRF protection — that library maintainers have already gotten right. Building from scratch means owning all of these details forever.

What is the difference between a session and a JWT?

A session is a server-side record of authenticated state — the server stores session data, and the client holds a session ID cookie that maps to it. A JWT (JSON Web Token) is a self-contained token — the client holds an encoded token containing the user's identity and claims, and the server verifies the signature rather than looking up a session. Sessions are easier to invalidate; JWTs work better for distributed systems and mobile apps.

What is OAuth and when should I use it?

OAuth (via "Sign in with Google", "Sign in with GitHub") lets users authenticate using credentials from a third-party provider, without creating a new password. Users benefit from using a trusted provider, and you benefit from not storing passwords. Use OAuth as a supplementary login method alongside email/password. The implementation involves redirect flows, exchanging authorisation codes for tokens, and storing the user's profile data in your database.

What is RBAC and how do I implement it?

Role-Based Access Control restricts user actions based on assigned roles (e.g., admin, editor, viewer). Implementation: add a role column to the users table (or a separate roles table for complex scenarios), check the user's role in API route handlers before performing sensitive operations, and enforce role-based restrictions at the database level with RLS policies. Most SaaS applications need only 2–4 roles — avoid over-engineering.

How do I implement "remember me" and session persistence?

"Remember me" extends the session expiry from a short period (30 minutes of inactivity) to a longer one (30 days). Implementation: when the user checks "remember me" at login, issue a session with a longer max-age and persistent cookie. Without this, session cookies expire when the browser closes. Never implement this by making sessions permanent — always set an appropriate expiry and implement refresh token rotation for long-lived sessions.

RadarTrek Intel — monthly score updates

We track 40+ tools so you don't have to. Score changes, new tools, and new guides — once a month, no spam.