Skip to main content

What are Users?

Users are individual accounts that can authenticate and access Directus. Each user has a unique email address, password (or authentication method), and is assigned to one or more roles that determine their permissions and access levels.
Users are stored in the directus_users system collection and can be managed through the API or admin interface.

User Structure

Users have both required system fields and optional profile information:

Required Fields

  • id - Unique identifier (UUID)
  • email - Unique email address (case-insensitive)
  • password - Hashed password
  • role - Assigned role ID
  • status - Account status (active, suspended, draft, invited)
  • provider - Authentication provider (default, ldap, oauth, etc.)

Optional Fields

  • first_name - User’s first name
  • last_name - User’s last name
  • avatar - Profile image (file ID)
  • language - Preferred interface language
  • theme - App theme preference (auto, light, dark)
  • tfa_secret - Two-factor authentication secret
  • email_notifications - Enable email notifications
  • title - Job title
  • description - User bio/description
  • tags - Organizational tags
  • location - Geographic location

Creating Users

Via API

From the source code (~/workspace/source/api/src/services/users.ts:190-200), creating a user:
  1. Validates email uniqueness (case-insensitive)
  2. Checks password against password policy
  3. Hashes the password securely
  4. Creates the user record
  5. Triggers user creation hooks

Email Validation

From the source code (~/workspace/source/api/src/services/users.ts:50-80):

Password Policies

From the source code (~/workspace/source/api/src/services/users.ts:87-118), passwords are validated against configurable policies:

User Status

Users can have different statuses:

Active

Fully functional account that can authenticate and access the system.

Invited

User has been invited but hasn’t completed registration.

Draft

User account exists but is not yet active.

Suspended

Account is temporarily disabled and cannot authenticate.
Suspended users cannot log in and their sessions are invalidated.

Inviting Users

Send invitation emails to new users:
From the source code (~/workspace/source/api/src/services/users.ts:153-164), the invitation process:
  1. Creates a user with status: invited
  2. Generates a JWT token with email and scope: invite
  3. Sends invitation email with acceptance link
  4. Token expires based on USER_INVITE_TOKEN_TTL setting

What are Roles?

Roles are groups that define shared permissions and access levels. Users are assigned to roles, which in turn are associated with policies containing permissions.

Role Structure

Admin Roles

Roles with admin_access: true bypass all permission checks:
Admin users have unrestricted access to all collections, fields, and items. Use this carefully.

App Access

Roles with app_access: true can access the Directus admin application:
Roles without app access can only use the API.

Creating Roles

From the source code (~/workspace/source/api/src/services/roles.ts:13-19), role creation is straightforward but changes to roles trigger cache clearing and user integrity checks.

Role Inheritance

Roles can inherit from parent roles:
From the source code (~/workspace/source/api/src/services/roles.ts:108-119), role nesting is validated to prevent circular references:

Policies and Access

Roles are linked to policies through the directus_access collection:
Multiple policies can be assigned to a single role, with permissions merged from all policies.

Deleting Roles

From the source code (~/workspace/source/api/src/services/roles.ts:46-106), deleting a role:
  1. Deletes all permissions associated with the role’s policies
  2. Deletes all presets for the role
  3. Suspends all users assigned to the role
  4. Sets users’ role to NULL
  5. Updates child roles to remove parent reference
Deleting a role suspends all users assigned to it. Reassign users to different roles before deletion to maintain their access.

Authentication Providers

Users can authenticate through multiple providers:

Default Provider

Standard email/password authentication.

LDAP Provider

OAuth Providers

Supported OAuth providers: Google, GitHub, Facebook, etc.

Two-Factor Authentication

Enabling TFA

Returns a QR code and secret for authenticator apps.

Enforcing TFA

Roles can require TFA for all users:

IP Access Restrictions

Limit role access to specific IP addresses:

User Sessions

From the source code (~/workspace/source/api/src/services/users.ts:123-133), user sessions can be cleared:
This is useful for:
  • Forcing users to re-authenticate
  • Security incidents
  • Role/permission changes

Common Use Cases

Content Team

Create Editor, Reviewer, and Publisher roles with progressive permissions for content workflows.

API Clients

Set up API-only roles without app access for external system integrations.

Department Access

Create department-specific roles with conditional permissions based on user attributes.

Customer Portal

Build customer-facing roles with limited access to their own data and public content.

Best Practices

Unique Email Addresses: Ensure email addresses are unique across all users, even with different casing.
Strong Password Policies: Configure password policies in settings to enforce complexity requirements.
Role-Based Design: Design roles based on job functions rather than individual users for easier management.
Minimal Admin Accounts: Limit the number of users with admin access to reduce security risks.
Enable TFA: Require two-factor authentication for sensitive roles like administrators.
Regular Audits: Periodically review user accounts and roles to remove inactive users and update permissions.
  • Permissions - Access control rules assigned to roles
  • Collections - Data that users and roles can access
  • Items - Records that users create and manage