Overview
django-allauth provides class-based views for all MFA workflows including TOTP, WebAuthn, and recovery codes. These views can be used directly or subclassed for customization.Base MFA Views
AuthenticateView
Source:allauth/mfa/base/views.py:28
Handles MFA authentication during login.
URL Name: mfa_authenticate
Template: mfa/authenticate.html
Form Classes:
AuthenticateForm- For TOTP/recovery codesAuthenticateWebAuthnForm- For WebAuthn
@login_stage_required(stage=AuthenticateStage.key)
Context:
form- The authentication formwebauthn_form- WebAuthn form (if enabled)js_data- JavaScript data for WebAuthn (request options)MFA_SUPPORTED_TYPES- List of enabled MFA types
ReauthenticateView
Source:allauth/mfa/base/views.py:117
Handles MFA re-authentication for sensitive operations.
URL Name: mfa_reauthenticate
Template: mfa/reauthenticate.html
Form Class: ReauthenticateForm
Decorators: @login_required
IndexView
Source:allauth/mfa/base/views.py:138
Displays MFA management dashboard showing all configured authenticators.
URL Name: mfa_index
Template: mfa/index.html
Decorators: @login_required
Context:
authenticators- Dictionary of authenticators by typeMFA_SUPPORTED_TYPES- List of enabled MFA typesis_mfa_enabled- Boolean indicating if user has MFA
TrustView
Source:allauth/mfa/base/views.py:163
Allows users to trust a browser/device to skip MFA for a period.
URL Name: mfa_trust
Template: mfa/trust.html
Decorators: @login_stage_required(stage=TrustStage.key)
Context:
trust_from- Current timestamptrust_until- When trust expires
TOTP Views
ActivateTOTPView
Source:allauth/mfa/totp/views.py:24
Handles TOTP authenticator activation with QR code display.
URL Name: mfa_activate_totp
Template: mfa/totp/activate_form.html
Form Class: ActivateTOTPForm
Decorators:
@redirect_if_add_not_allowed@reauthentication_required
form- Activation form with secret fieldtotp_svg- SVG markup for QR codetotp_svg_data_uri- Data URI for QR code imagetotp_url- Rawotpauth://URL
mfa_view_recovery_codes (if generated) or mfa_index
DeactivateTOTPView
Source:allauth/mfa/totp/views.py:75
Handles TOTP authenticator deactivation.
URL Name: mfa_deactivate_totp
Template: mfa/totp/deactivate_form.html
Form Class: DeactivateTOTPForm
Decorators: @login_required, @reauthentication_required
Success URL: mfa_index
WebAuthn Views
AddWebAuthnView
Source:allauth/mfa/webauthn/views.py:31
Handles adding new WebAuthn credentials (security keys, biometrics).
URL Name: mfa_add_webauthn
Template: mfa/webauthn/add_form.html
Form Class: AddWebAuthnForm
Decorators:
@redirect_if_add_not_allowed@reauthentication_required
form- Add formjs_data- JavaScript data withcreation_optionsfor WebAuthn API
mfa_view_recovery_codes (if generated) or mfa_index
ListWebAuthnView
Source:allauth/mfa/webauthn/views.py:65
Lists all WebAuthn authenticators for the user.
URL Name: mfa_list_webauthn
Template: mfa/webauthn/authenticator_list.html
Decorators: @login_required
Context:
authenticators- QuerySet of WebAuthn authenticators
EditWebAuthnView
Source:allauth/mfa/webauthn/views.py:163
Allows renaming WebAuthn authenticators.
URL Name: mfa_edit_webauthn
Template: mfa/webauthn/edit_form.html
Form Class: EditWebAuthnForm
Decorators: @reauthentication_required
Success URL: mfa_list_webauthn
RemoveWebAuthnView
Source:allauth/mfa/webauthn/views.py:81
Handles WebAuthn authenticator removal.
URL Name: mfa_remove_webauthn
Template: mfa/webauthn/authenticator_confirm_delete.html
Decorators: @reauthentication_required
Success URL: mfa_list_webauthn
LoginWebAuthnView
Source:allauth/mfa/webauthn/views.py:103
Handles passwordless WebAuthn login.
URL Pattern: /accounts/webauthn/login/
Form Class: LoginWebAuthnForm
Note: Only available if MFA_PASSKEY_LOGIN_ENABLED = True
ReauthenticateWebAuthnView
Source:allauth/mfa/webauthn/views.py:131
Handles re-authentication using WebAuthn.
URL Name: mfa_reauthenticate_webauthn
Template: mfa/webauthn/reauthenticate.html
Form Class: ReauthenticateWebAuthnForm
Context:
form- Re-authentication formjs_data- JavaScript data withrequest_options
SignupWebAuthnView
Source:allauth/mfa/webauthn/views.py:183
Handles WebAuthn credential creation during signup.
URL Name: mfa_signup_webauthn
Template: mfa/webauthn/signup_form.html
Form Class: SignupWebAuthnForm
Decorators: @login_stage_required(stage=PasskeySignupStage.key)
Note: Only available if MFA_PASSKEY_SIGNUP_ENABLED = True
Recovery Codes Views
GenerateRecoveryCodesView
Source:allauth/mfa/recovery_codes/views.py:19
Generates new recovery codes (regenerates if they already exist).
URL Name: mfa_generate_recovery_codes
Template: mfa/recovery_codes/generate.html
Form Class: GenerateRecoveryCodesForm
Decorators: @reauthentication_required
Success URL: mfa_view_recovery_codes
Context:
form- Generation formunused_code_count- Number of unused codes (before regeneration)
ViewRecoveryCodesView
Source:allauth/mfa/recovery_codes/views.py:83
Displays recovery codes to the user.
URL Name: mfa_view_recovery_codes
Template: mfa/recovery_codes/index.html
Decorators: @login_required
Context:
unused_codes- List of unused recovery codestotal_count- Total number of codes
DownloadRecoveryCodesView
Source:allauth/mfa/recovery_codes/views.py:55
Provides recovery codes as a downloadable text file.
URL Name: mfa_download_recovery_codes
Template: mfa/recovery_codes/download.txt
Content Type: text/plain
Decorators: @login_required, @never_cache
Response Headers:
