Overview
Nguhöe EHR uses Laravel Fortify as its headless authentication backend. Fortify provides robust authentication features including registration, login, password reset, email verification, and two-factor authentication (2FA).Configuration File
Fortify configuration is located atconfig/fortify.php.
Authentication Guard
The authentication guard Fortify uses for authenticating users. Must correspond to a guard defined in
config/auth.php.Password Broker
The password broker used for password reset functionality. Must correspond to a broker defined in
config/auth.php.Username Configuration
The model attribute used as the username field during authentication.
The field name for email in password reset requests.
Automatically lowercase usernames before saving to the database. Recommended for email-based authentication.
Routing Configuration
The path users are redirected to after successful authentication or password reset.
URL prefix for all Fortify routes. Leave empty for no prefix.
Subdomain for Fortify routes. Useful for multi-tenant applications.
Middleware applied to all Fortify routes.
Rate Limiting
Rate limiters for authentication attempts. Protects against brute-force attacks.
View Routes
Enable Fortify view routes. Set to
false for API-only applications or when using Inertia.js.Enabled Features
Array of enabled Fortify features. Enable or disable authentication features as needed.
Available Features
User Registration
GET /register- Registration formPOST /register- Process registration
Password Reset
GET /forgot-password- Request password resetPOST /forgot-password- Send reset linkGET /reset-password/{token}- Reset password formPOST /reset-password- Process password reset
config/auth.php:
Email Verification
GET /email/verify- Email verification noticeGET /email/verify/{id}/{hash}- Verify emailPOST /email/verification-notification- Resend verification email
verified middleware:
Two-Factor Authentication (2FA)
POST /user/two-factor-authentication- Enable 2FADELETE /user/two-factor-authentication- Disable 2FAGET /user/two-factor-qr-code- Get QR code for setupGET /user/two-factor-recovery-codes- Get recovery codesPOST /user/two-factor-recovery-codes- Regenerate recovery codesPOST /two-factor-challenge- Verify 2FA code during login
confirm: Require password confirmation before enabling 2FAconfirmPassword: Require password confirmation before disabling 2FAwindow: Time drift tolerance in seconds (default: 0)
Profile Updates
PUT /user/profile-information- Update profile
Password Updates
PUT /user/password- Update password
Authentication Configuration
Authentication guards and providers are configured inconfig/auth.php.
Default Guard
Web Guard
User Provider
Session Configuration
Session settings control user session behavior. Configure in.env and config/session.php.
Session storage driver.Options:
file, cookie, database, memcached, redisSession lifetime in minutes. Users are logged out after this period of inactivity.
Encrypt session data before storage.
Session Cookie Security
Configured inconfig/session.php:
Password Confirmation
Number of seconds before password confirmation expires. Default is 3 hours (10800 seconds).
Middleware
Nguhöe EHR uses the following authentication middleware:Built-in Middleware
auth- Require authenticationguest- Allow only unauthenticated usersverified- Require email verification
Usage Examples
Security Best Practices
Production Checklist
- Enable HTTPS and set
SESSION_SECURE_COOKIE=true - Set appropriate
SESSION_LIFETIMEbased on security requirements - Enable email verification for new registrations
- Encourage or require two-factor authentication for privileged users
- Use strong password requirements (configured in User model)
- Monitor failed login attempts
- Regularly review and revoke old sessions
Password Requirements
Configure password validation in your registration form request:Rate Limiting
Fortify includes built-in rate limiting for authentication attempts:- Login: 5 attempts per minute per IP + email combination
- Two-factor: 5 attempts per minute per IP + email combination
- Password reset: 60 seconds between requests (configured in
config/auth.php)
Session Security
Recommended session settings for production:Email Notifications
Fortify sends emails for various authentication events:Password Reset Email
Sent when users request password reset. Configure mail settings in.env:
Email Verification Email
Sent automatically when email verification is enabled and a user registers.Customization
Custom Login Logic
Register custom logic inapp/Providers/FortifyServiceProvider.php:
Custom Views
Fortify uses Inertia.js for views in Nguhöe EHR. Views are located inresources/js/pages/:
login.tsx- Login pageregister.tsx- Registration pageforgot-password.tsx- Password reset requestreset-password.tsx- Password reset formverify-email.tsx- Email verification notice
Troubleshooting
”Unauthenticated” Error
Ensure routes are protected withauth middleware and user is logged in.
Email Verification Not Working
- Check that
Features::emailVerification()is enabled inconfig/fortify.php - Verify mail configuration in
.env - Ensure routes are protected with
verifiedmiddleware - Check that User model implements
MustVerifyEmailinterface
Two-Factor Authentication Issues
- Verify
Features::twoFactorAuthentication()is enabled - Ensure user has confirmed their password before enabling 2FA
- Check time synchronization on server (TOTP is time-sensitive)
- Try using recovery codes if TOTP code fails
Session Expiring Too Quickly
IncreaseSESSION_LIFETIME in .env:
Password Reset Emails Not Sending
- Check mail configuration in
.env - Test mail connection:
php artisan tinkerthenMail::raw('Test', fn($msg) => $msg->to('[email protected]')->subject('Test')); - Check logs in
storage/logs/laravel.log - Verify
MAIL_FROM_ADDRESSis set