Architecture & Security Model
Explore the multi-tier authentication architecture that separates browser sessions from external API bearer tokens.
System Boundaries Overview
How Nuxt Bearer Auth Isolates Tokens
Browser
Vue / Nuxt SPA
Nuxt Server
Nitro Auth Gateway
Redis Cache
Session Store (TTL)
External API
Laravel / REST API
Browser sends login request to local Nuxt endpoint (/api/auth/login).
Interactive Sequence Flows
Login & Session Creation
User enters credentials. Nuxt authenticates with your backend API, receives the bearer token, stores it securely in Redis, and issues an HTTP-only cookie.
The 5 Architectural Layers
How responsibilities are partitioned across the stack.
Client / Nuxt Composable Layer
Provides reactive state (user, isAuthenticated, status, loading) and action composables (login, logout, refresh, verifyOtp) via useBearerAuth(). Holds only session state, zero raw bearer tokens.
Nitro Server Auth Routes Layer
Local endpoints mounted under /api/auth/* (/login, /logout, /me, /refresh, /sessions) that handle CSRF verification, input normalization, and request proxying.
Session Manager Layer
Generates cryptographically random UUID session IDs, issues secure HTTP-only cookies, updates last-activity timestamps, manages sliding session TTLs, and indexes multi-device logins under user_sessions:userId sets.
Redis Storage Layer
High-speed in-memory database storing JSON serialized session payloads (session:<uuid>) and active device session sets with automated expiration.
External API Adapter Layer
Universal HTTP caller (callAuthApi) that resolves server-held bearer tokens and proxies requests to external backends with dynamic response path mapping.