Overview
The API uses a custom Redis-based token guard — not Laravel Passport, Sanctum, or JWT. This is defined inapp/Services/Redis/.
How it works
Token creation
When a user logs in (SessionService::createSession()):
- Credentials validated via
Auth::guard()->retrieveByCredentials() - Token generated:
md5(uniqid($userId, true)) - Token stored in Redis with ~1 year expiry (31,557,600 seconds)
- Session record created in the
sessionsdatabase table - Token returned to client
Token validation
On every authenticated request:RedisGuard::user()extracts token from request- Looks up user ID in Redis by token
- Loads
Usermodel from database - Sets as current authenticated user
Key files
Guard registration
Inapp/Providers/AuthServiceProvider.php:
config/auth.php:
Middleware layers
The API uses three custom auth middleware:auth:api — Standard token auth
Standard Laravel auth middleware using the custom redis.token guard. Requires a valid token. Returns 401 if missing/invalid.
Used on most authenticated endpoints:
web.api — Hybrid auth
app/Http/Middleware/WebAPI.php — the most complex auth layer. Tries three methods in order:
1
Existing Auth::user()
If a user is already authenticated (e.g., via session), use that.
2
Valid signed URL
If the request has a valid Laravel signed URL signature, authenticate via that.
3
Encrypted secret
If a
secret parameter exists in the request, decrypt it and treat the decrypted value as a user ID. Sets Auth::user() to that user.internal — Admin-only
app/Http/Middleware/API/Internal.php — checks if the authenticated user has role_id = 200 (Internal role). Returns 403 if not.
Used on admin operations:
Middleware stack
Global middleware applied to all requests (fromapp/Http/Kernel.php):
CheckForMaintenanceModeValidatePostSizeTrimStrings(excludes password fields)ConvertEmptyStringsToNullTrustProxies(trusts all proxies, X-Forwarded-All)SecureHeaders— removes X-Powered-By, Server headers; adds HSTS, X-Frame-Options, X-Content-Type-Options, X-XSS-ProtectionTrustedOrigins— CORS validation againstapp.trusted_origins(exact) andapp.whitelisted_origins(substring)
throttle:300,1(300 requests per minute)bindings(route model binding)ETag(HTTP caching via ETags)