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
| File | Purpose |
|---|---|
app/Services/Redis/RedisGuard.php | Guard implementation — token creation, lookup, deletion |
app/Services/Redis/RedisGuardTrait.php | Implements Laravel Guard interface methods |
app/Services/Redis/RedisClient.php | Low-level Redis operations (get, set, expire, delete) |
app/Models/Services/SessionService.php | Login/logout business logic |
app/Models/Session.php | Session database model |
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:
Returns 401 if none of the three methods succeed.
Used on sensitive management endpoints:
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)