Two-Factor Authentication
The GB App uses Laravel Fortify for Two-Factor Authentication (2FA) functionality. Users can enable TOTP-based 2FA using authenticator apps like Google Authenticator or Authy.Two-Factor Authentication is managed through Laravel Jetstream’s built-in features. The application uses the
TwoFactorAuthenticatable trait on the User model.Enable Two-Factor Authentication
Enable 2FA for the authenticated user.Headers
Bearer token or valid session
CSRF token for session-based requests
Response
Returns a 200 status code on success. The user must then retrieve the QR code and recovery codes.Example Request
Get Two-Factor QR Code
Retrieve the QR code for configuring the authenticator app.Response
SVG image of the QR code to scan with authenticator app
Example Request
Example Response
Get Recovery Codes
Retrieve the two-factor authentication recovery codes.Response
Array of recovery codes (typically 8 codes)
Example Request
Example Response
Regenerate Recovery Codes
Generate new recovery codes (invalidates existing ones).Headers
Bearer token or valid session
CSRF token for session-based requests
Response
Returns new recovery codes in the same format as GET endpoint.Example Request
Disable Two-Factor Authentication
Disable 2FA for the authenticated user.Headers
Bearer token or valid session
CSRF token for session-based requests
Response
Returns a 200 status code on success.Example Request
Two-Factor Challenge
When 2FA is enabled, users must complete a two-factor challenge after providing credentials.Verify with Code
Request Body
6-digit code from authenticator app
One-time recovery code
Example Request (TOTP Code)
Example Request (Recovery Code)
User Model Fields
The User model includes these 2FA-related fields:Timestamp when 2FA was confirmed
Setup Flow
- User enables 2FA via
POST /user/two-factor-authentication - System generates secret and recovery codes
- User retrieves QR code via
GET /user/two-factor-qr-code - User scans QR code with authenticator app
- User saves recovery codes from
GET /user/two-factor-recovery-codes - User confirms 2FA by entering code on next login
Best Practices
- Store recovery codes securely - Users should save them in a password manager
- Provide backup authentication - Recovery codes ensure account access if device is lost
- Time sync important - TOTP codes require accurate system time
- Rate limit attempts - Prevent brute force attacks on 2FA codes
- Educate users - Provide clear instructions for setup and recovery