Authentication System
The GB App uses Laravel Sanctum for API authentication with session-based authentication for web routes. The application supports both local authentication and LDAP integration.Authentication Middleware
All protected routes use the following middleware stack:auth:sanctum- Sanctum authenticationconfig('jetstream.auth_session')- Session verificationverified- Email verification check
Get Authenticated User
Retrieve the currently authenticated user’s information.Headers
Bearer token for API authentication
Content type header
Response
User ID
User’s full name
Username for authentication
User’s email address
User type (e.g., ‘admin’, ‘designer’, ‘customer’)
Sales representative code
National ID number
Whether user authenticates via LDAP
Array of role names assigned to the user
Array of permission names granted to the user
URL to user’s profile photo
Example Request
Example Response
Login Flow
The application uses Laravel Fortify and Jetstream for authentication flows:- Web Login: Session-based authentication via
/loginroute - API Login: Token-based via Sanctum token creation
- LDAP Integration: Automatic authentication for LDAP users
Session Management
All web routes require:- Valid session cookie
- CSRF token for state-changing operations
- Email verification (for verified middleware)
LDAP Authentication
Users withis_ldap_user = true authenticate against the configured LDAP server:
- Automatic user provisioning on first login
- Synced user attributes from LDAP directory
- GUID-based user matching
Logout
To logout, use Laravel’s built-in logout endpoint:Error Responses
Error message describing the authentication failure
Common Error Codes
| Status Code | Description |
|---|---|
401 | Unauthenticated - Invalid or missing token |
403 | Forbidden - User lacks required permissions |
419 | CSRF token mismatch |
429 | Too many login attempts |
Example Error Response
Best Practices
- Always use HTTPS in production for token transmission
- Store tokens securely - Never expose in client-side code
- Implement token rotation for long-lived sessions
- Use appropriate scopes for API tokens
- Monitor failed login attempts for security threats