Authentication Methods
Directus supports multiple authentication drivers that can be used individually or in combination:- Local - Email and password authentication
- OAuth 2.0 - Generic OAuth 2.0 provider integration
- OpenID - OpenID Connect authentication
- LDAP - Active Directory and LDAP integration
- SAML - SAML 2.0 single sign-on
Local Authentication
The default authentication method using email and password stored in Directus.Configuration
Login Flow
Password Hashing
Passwords are hashed using Argon2, a secure password hashing algorithm:Authentication Modes
Directus supports three authentication modes:JSON Mode (Default)
Tokens returned in JSON response:Cookie Mode
Tokens stored in HTTP-only cookies:Session Mode
Long-lived session in cookie:OAuth 2.0
Integrate with any OAuth 2.0 provider (Google, GitHub, Facebook, etc.).Configuration
OAuth Login Flow
User Mapping
Map OAuth profile fields to Directus user fields:OpenID Connect
Modern authentication protocol built on OAuth 2.0.Configuration
Token Refresh
OpenID tokens are automatically refreshed:LDAP Authentication
Integrate with Active Directory or LDAP servers.Configuration
LDAP Login
Group-based Roles
Map LDAP groups to Directus roles:- Create role in Directus with matching name
- LDAP users in that group automatically get the role
- Roles sync on each login
SAML 2.0
Enterprise single sign-on via SAML.Configuration
Token Management
Access Tokens
Short-lived JWT tokens (default 15 minutes):Refresh Tokens
Long-lived tokens to get new access tokens (default 7 days):Token Refresh
Two-Factor Authentication
Enable TOTP-based 2FA for users:Session Management
Login Stall Time
Prevent timing attacks:Session Security
SSO Events
Hook into authentication events:Best Practices
Use Environment Variables for Secrets
Use Environment Variables for Secrets
Never commit OAuth secrets, LDAP passwords, or API keys. Use environment variables.
Enable Two-Factor Authentication
Enable Two-Factor Authentication
Require 2FA for admin users to prevent unauthorized access.
Use HTTPS in Production
Use HTTPS in Production
Always use HTTPS for OAuth callbacks and cookie-based authentication.
Implement Role Mapping
Implement Role Mapping
Use group-based role mapping with SSO to automate access control.
Monitor Failed Login Attempts
Monitor Failed Login Attempts
Track failed logins in the activity log and implement rate limiting.