Settings¶
Defaults and customization¶
TRENCH_AUTH
dict in your settings.py
:TRENCH_AUTH = {
"USER_MFA_MODEL": "trench.MFAMethod",
"USER_ACTIVE_FIELD": "is_active",
"BACKUP_CODES_QUANTITY": 5,
"BACKUP_CODES_LENGTH": 12,
"BACKUP_CODES_CHARACTERS": (string.ascii_letters + string.digits),
"SECRET_KEY_LENGTH": 32,
"DEFAULT_VALIDITY_PERIOD": 30,
"CONFIRM_DISABLE_WITH_CODE": False,
"CONFIRM_BACKUP_CODES_REGENERATION_WITH_CODE": True,
"ALLOW_BACKUP_CODES_REGENERATION": True,
"ENCRYPT_BACKUP_CODES": True,
"APPLICATION_ISSUER_NAME": "MyApplication",
"MFA_METHODS": {
"email": {
"VERBOSE_NAME": _("email"),
"VALIDITY_PERIOD": 60 * 10,
"HANDLER": "trench.backends.basic_mail.SendMailMessageDispatcher",
"SOURCE_FIELD": "email",
"EMAIL_SUBJECT": _("Your verification code"),
"EMAIL_PLAIN_TEMPLATE": "trench/backends/email/code.txt",
"EMAIL_HTML_TEMPLATE": "trench/backends/email/code.html",
},
# Your other backends here
}
}
Properties¶
Property |
Description |
Type |
Default value |
---|---|---|---|
|
You can specify your own model for storing MFA data. For compatibility reasons it is recommended to inherit from the |
|
|
|
Field on |
|
|
|
Number of backup codes to be generated. |
|
|
|
Number of characters that the backup code should consist of. |
|
|
|
Characters that should be used to generate backup codes. |
|
|
|
Defines whether backup codes should be encrypted before storing them into the database. |
|
|
|
Length of the shared secret key. Note: secrets must be at least 160 bits. |
|
|
|
Period when OTP code validates positively (in seconds). Becomes a default if no validity period has been declared on a specific authentication method. |
|
|
|
When set to |
|
|
|
When set to |
|
|
|
When set to |
|
|
|
Issuer name for the QR code generator. |
|
|
|
A dictionary which holds all authentication methods and its settings. New method can be added as a next item. |
|
Described in backends section. |
Method item properties¶
Property |
Description |
Type |
---|---|---|
|
Full name of the method. |
|
|
OTP code validity (in seconds). |
|
|
String path pointing to the location of your backend class definition. |
|