Actions100
- Activity Actions
- Asset Actions
- Authentication Actions
- Collection Actions
- Extension Actions
- Field Actions
- File Actions
- Folder Actions
- Item Actions
- Permission Actions
- Preset Actions
- Relation Actions
- Revisions Actions
- Roles Actions
- Settings Actions
- Users Actions
- Utilities Actions
Overview
The Directus - Users: Generate 2FA operation in n8n allows you to generate a Two-Factor Authentication (2FA) secret for the currently authenticated user in your Directus instance. This is typically used as the first step when enabling 2FA, providing the necessary secret that can be added to an authenticator app (such as Google Authenticator or Authy).
Common scenarios:
- Enabling 2FA for enhanced account security.
- Automating onboarding processes where users are required to set up 2FA.
- Integrating with custom user management workflows.
Practical example:
A workflow could prompt a user for their password, call this node to generate a 2FA secret, and then display the QR code or secret to the user so they can add it to their authenticator app.
Properties
Name | Type | Meaning |
---|---|---|
Password | String | The password of the currently authenticated user. Required for security. |
Output
The output will be a JSON object containing the result of the 2FA generation request. Typically, this includes the 2FA secret and possibly other metadata needed to configure an authenticator app.
Example output structure:
{
"secret": "BASE32SECRET",
"otpauth_url": "otpauth://totp/Directus:[email protected]?secret=BASE32SECRET&issuer=Directus"
}
Note: The actual fields may vary depending on the Directus API version and configuration.
Dependencies
- Directus API: You must have access to a running Directus instance.
- API Credentials: The node requires valid Directus API credentials configured in n8n under the name
directusApi
. - User Authentication: The operation acts on the currently authenticated user.
Troubleshooting
Common issues:
Invalid Password: If the provided password is incorrect, the API will reject the request.
- Error message:
"Invalid credentials"
or similar. - Resolution: Ensure the password matches the current user's password.
- Error message:
Missing Credentials: If the Directus API credentials are not set up in n8n.
- Error message:
"No credentials found"
or similar. - Resolution: Configure the correct Directus API credentials in n8n.
- Error message:
Insufficient Permissions: The user may lack permission to enable 2FA.
- Error message:
"Forbidden"
or"Not authorized"
- Resolution: Check the user's role and permissions in Directus.
- Error message:
Links and References
- Directus Documentation: Enabling Two-Factor Authentication
- n8n Documentation: Using Credentials
- TOTP (Time-based One-Time Password) Standard