Overview
MediaStream uses Laravel Fortify to provide a robust, secure authentication system with support for standard login, user registration, and two-factor authentication (2FA). All authentication endpoints use session-based authentication with CSRF protection. API clients must include a valid CSRF token with requests that modify data.Authentication Features
User Registration
Create new user accounts with email and password
Login
Authenticate users with email and password
Two-Factor Authentication
Enhanced security with TOTP-based 2FA
Session Management
Automatic session handling and token rotation
Security Features
Rate Limiting
Authentication endpoints are protected by rate limiting to prevent brute-force attacks:- Login: 5 attempts per minute per email and IP address combination
- Two-Factor Challenge: 5 attempts per minute per session
CSRF Protection
All authentication endpoints require CSRF token validation. The token must be:- Retrieved from the
/sanctum/csrf-cookieendpoint - Included in the
X-XSRF-TOKENheader for all subsequent requests
Password Requirements
Passwords must meet Laravel’s default password validation rules:- Minimum 8 characters
- Must be confirmed (matching
password_confirmationfield) - Cannot be commonly used passwords
Base URL
All authentication endpoints are relative to your application’s base URL:Authentication Flow
Standard Login Flow
Two-Factor Authentication Flow
Common Response Codes
Authentication successful
Invalid credentials or authentication required
Validation errors in request data
Rate limit exceeded
Error Response Format
Validation errors follow Laravel’s standard format:Next Steps
Register Users
Create new accounts
Login
Authenticate users
Enable 2FA
Setup two-factor auth