Hands-On Reasoning Lab & Phase Exit
Prove that the authentication model is understood before Supabase Auth implementation
Phase 16 - Authentication Fundamentals
Volume 05 - Authentication & Security
Architecture milestone
Classify
v
Threat model
v
Draw trust boundaries
v
Explain
v
Proceed to Phase 17
Phase 16 builds the security mental model before any Supabase Auth integration code is introduced.
Hands-on reasoning lab
Phase 16 is intentionally concept-heavy. The lab tests whether you can reason about authentication architecture
before a provider SDK hides the mechanics.
Lab A - Classify the concept
Scenario Concept
User types email Identification / claimed identity
Password verified Authentication
Browser receives authenticated continuity state Session
NestJS verifies access token Authentication evidence verification
User may update only Tasks in their Workspace Authorization
Task cannot transition directly DONE -> TODO Business rule, not auth
Lab B - Find the security mistake
• Frontend sends userId in POST /tasks and service trusts it as owner.
• JWT payload is base64-decoded and sub is trusted without signature verification.
• Refresh token is placed in a URL query parameter.
• Authorization header is written to request logs.
• JWT is stored in localStorage without discussing XSS risk.
• Cookie auth is enabled with SameSite=None but CSRF is never considered.
• CORS allowlist is treated as proof that the request is authenticated.
• Logout only hides the dashboard but leaves a valid provider session alive.
Lab C - Draw the future TaskFlow flow
On paper, draw: User -> Supabase Auth -> session/access token -> Next.js -> Authorization header -> NestJS guard
-> trusted subject -> TasksService -> membership/ownership check -> Prisma. Label every point where trust
changes.
Exercise levels
Level Challenge
1 - Follow Explain AuthN vs AuthZ, access vs refresh token, and HttpOnly vs JavaScript-readable storage.
2 - Modify Design a logout lifecycle for a shared-office computer where the user expects sign-out to terminate future token
refresh.
3 - Implement (design) Write pseudocode for a NestJS guard that returns 401 for missing, expired, wrong-issuer, or invalid-signature
tokens without implementing cryptography yourself.
4 - Engineer Threat-model authentication for an HRIS payroll approval screen. Identify authenticator strength, session
storage, re-authentication, authorization, audit logging, token exposure, logout/revocation, and recovery risks.
Architecture oral exam
• Why does a browser-supplied userId not prove identity?
• Why is decoding a JWT different from verifying it?
• What does aud protect against?
• Why should access tokens usually be short-lived?
• Why is a refresh token more sensitive than an access token?
• Why can HttpOnly cookies reduce token theft but still require CSRF thinking?
• Why is CORS not an authentication mechanism?
• What is the difference between 401 and 403 in TaskFlow reasoning?
• What should never appear in authentication logs?
• What responsibility will Supabase Auth own versus NestJS?
Phase exit checklist
• You can explain identity, authenticator, authentication, session, token, and authorization separately.
• You understand why TaskFlow will not implement password hashing itself.
• You can explain cookie attributes Secure, HttpOnly, and SameSite.
• You can explain why localStorage/sessionStorage token use creates XSS exposure.
• You can identify JWT iss, sub, aud, exp, nbf, iat, and jti.
• You know that decoding a JWT does not verify it.
• You understand access vs refresh tokens and refresh rotation conceptually.
• You understand XSS, CSRF, CORS, and HTTPS as different concerns.
• You can draw the planned Supabase Auth -> Next.js -> NestJS guard flow.
• You are ready to integrate Supabase Auth without treating it as magic.
Figure 1 - Phase 16 exit architecture
Credentials/authenticator
v
Supabase Auth (next phase implementation)
v
Authenticated session + access token
v
Next.js session boundary
v
NestJS token verification (Phase 18)
v
Trusted identity
v
Authorization + business logic
Phase 16 ends when the learner can explain every arrow before writing provider-specific code.