Authentication & Authorization
Laravel Sanctum Integration
The project uses Laravel Sanctum with session-based authentication (stateful).
- Workflow:
- Frontend requests a CSRF cookie from the backend (
/sanctum/csrf-cookie). - User submits credentials to the login endpoint.
- Backend issues a session cookie.
- Subsequent requests include the session cookie and a
X-XSRF-TOKENheader automatically.
- Frontend requests a CSRF cookie from the backend (
- Middleware: Routes are protected using
nuxt-auth-sanctummiddleware. Custom global middleware (02.check_login_status.global.js) ensures that authenticated users always have their profile data populated in the Pinia store.