Session auth
For browser-based SPAs and the admin panel. Login via form and use Laravel session cookies.
Bearer token auth
For programmatic API access to
/api/v1/* endpoints. Pass a Sanctum personal access token.Session-based authentication
Session auth is used by the admin panel and any browser SPA that targets web routes under theauth + verified middleware group.
Login
The user’s email address.
The user’s password.
When
true, the session persists beyond the browser session via a long-lived remember-me cookie.Login is rate-limited to 5 attempts per email/IP combination. Subsequent attempts are locked out until the rate-limit window expires.
/dashboard. A 422 is returned when credentials are invalid or rate limited.
Logout
POST /logout invalidates the current session and regenerates the CSRF token.
cURL
CSRF protection for SPA requests
Before making any state-changing request (POST, PATCH, PUT, DELETE) from a JavaScript SPA, fetch the CSRF cookie first. This sets the XSRF-TOKEN cookie that Axios/Fetch reads automatically.
cURL (CSRF cookie)
XSRF-TOKEN cookie. Include it as the X-XSRF-TOKEN header (or let Axios handle it automatically) on every subsequent mutating request.
Fetch the CSRF cookie
Send
GET /sanctum/csrf-cookie. The server responds with a 204 and sets the XSRF-TOKEN cookie.Bearer token authentication
Sanctum personal access tokens authenticate requests to theGET|POST /api/v1/* routes. Tokens are stored in the personal_access_tokens table.
Obtaining a token
Create a token programmatically via thecreateToken method on the User model (typically done in a one-time setup script or a dedicated token-issuance endpoint your team controls):
PHP (token creation)
Making authenticated API requests
Pass the token in theAuthorization header as a Bearer token on every request to /api/v1/*.
Rate limiting
Allauth:sanctum protected endpoints under /api/v1/* are throttled at 30 requests per minute per token. Exceeding this limit returns a 429 Too Many Requests response.
Route summary
| Method | Path | Middleware | Purpose |
|---|---|---|---|
GET | /sanctum/csrf-cookie | — | Set CSRF cookie for SPA |
POST | /login | guest | Authenticate and start session |
POST | /logout | auth | Invalidate session |
GET | /api/v1/* | auth:sanctum, throttle:30,1 | Bearer token protected API |
Web admin routes (
/admin/cotizaciones/*, /bloques/*) require the auth and verified middleware — the logged-in user must have a verified email address before those routes are accessible.