diff --git a/passbook/core/settings.py b/passbook/core/settings.py
index fa1ebea45..5e4c7e716 100644
--- a/passbook/core/settings.py
+++ b/passbook/core/settings.py
@@ -74,7 +74,7 @@ INSTALLED_APPS = [
'passbook.oauth_client',
'passbook.oauth_provider',
'passbook.saml_idp',
- 'passbook.tfa',
+ 'passbook.totp',
]
# Message Tag fix for bootstrap CSS Classes
diff --git a/passbook/tfa/__init__.py b/passbook/tfa/__init__.py
deleted file mode 100644
index 0dc550c0a..000000000
--- a/passbook/tfa/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-"""passbook tfa Header"""
-__version__ = '0.0.1-alpha'
-default_app_config = 'passbook.tfa.apps.PassbookTFAConfig'
diff --git a/passbook/tfa/apps.py b/passbook/tfa/apps.py
deleted file mode 100644
index 4d94523bd..000000000
--- a/passbook/tfa/apps.py
+++ /dev/null
@@ -1,11 +0,0 @@
-"""passbook 2FA AppConfig"""
-
-from django.apps.config import AppConfig
-
-
-class PassbookTFAConfig(AppConfig):
- """passbook TFA AppConfig"""
-
- name = 'passbook.tfa'
- label = 'passbook_tfa'
- mountpoint = 'user/tfa/'
diff --git a/passbook/tfa/urls.py b/passbook/tfa/urls.py
deleted file mode 100644
index b675f794c..000000000
--- a/passbook/tfa/urls.py
+++ /dev/null
@@ -1,14 +0,0 @@
-"""passbook 2FA Urls"""
-
-from django.urls import path
-
-from passbook.tfa import views
-
-urlpatterns = [
- path('', views.index, name='tfa-index'),
- path('qr/', views.qr_code, name='tfa-qr'),
- path('verify/', views.verify, name='tfa-verify'),
- # path('enable/', views.TFASetupView.as_view(), name='tfa-enable'),
- path('disable/', views.disable, name='tfa-disable'),
- path('user_settings/', views.user_settings, name='tfa-user_settings'),
-]
diff --git a/passbook/totp/__init__.py b/passbook/totp/__init__.py
new file mode 100644
index 000000000..e64737713
--- /dev/null
+++ b/passbook/totp/__init__.py
@@ -0,0 +1,3 @@
+"""passbook totp Header"""
+__version__ = '0.0.1-alpha'
+default_app_config = 'passbook.totp.apps.PassbookTOTPConfig'
diff --git a/passbook/totp/apps.py b/passbook/totp/apps.py
new file mode 100644
index 000000000..1597b0c76
--- /dev/null
+++ b/passbook/totp/apps.py
@@ -0,0 +1,11 @@
+"""passbook TOTP AppConfig"""
+
+from django.apps.config import AppConfig
+
+
+class PassbookTOTPConfig(AppConfig):
+ """passbook TOTP AppConfig"""
+
+ name = 'passbook.totp'
+ label = 'passbook_totp'
+ mountpoint = 'user/totp/'
diff --git a/passbook/tfa/forms.py b/passbook/totp/forms.py
similarity index 65%
rename from passbook/tfa/forms.py
rename to passbook/totp/forms.py
index 5f296ffdf..ff35a1226 100644
--- a/passbook/tfa/forms.py
+++ b/passbook/totp/forms.py
@@ -1,12 +1,12 @@
-"""passbook 2FA Forms"""
+"""passbook TOTP Forms"""
from django import forms
from django.core.validators import RegexValidator
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
-TFA_CODE_VALIDATOR = RegexValidator(r'^[0-9a-z]{6,8}$',
- _('Only alpha-numeric characters are allowed.'))
+TOTP_CODE_VALIDATOR = RegexValidator(r'^[0-9a-z]{6,8}$',
+ _('Only alpha-numeric characters are allowed.'))
class PictureWidget(forms.widgets.Widget):
@@ -16,37 +16,37 @@ class PictureWidget(forms.widgets.Widget):
return mark_safe("" % value) # nosec
-class TFAVerifyForm(forms.Form):
- """Simple Form to verify 2FA Code"""
+class TOTPVerifyForm(forms.Form):
+ """Simple Form to verify TOTP Code"""
order = ['code']
- code = forms.CharField(label=_('Code'), validators=[TFA_CODE_VALIDATOR],
+ code = forms.CharField(label=_('Code'), validators=[TOTP_CODE_VALIDATOR],
widget=forms.TextInput(attrs={'autocomplete': 'off'}))
def __init__(self, *args, **kwargs):
- super(TFAVerifyForm, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
# This is a little helper so the field is focused by default
self.fields['code'].widget.attrs.update({'autofocus': 'autofocus'})
-class TFASetupInitForm(forms.Form):
- """Initial 2FA Setup form"""
- title = _('Set up 2FA')
+class TOTPSetupInitForm(forms.Form):
+ """Initial TOTP Setup form"""
+ title = _('Set up TOTP')
device = None
confirmed = False
qr_code = forms.CharField(widget=PictureWidget, disabled=True, required=False,
- label=_('Scan this Code with your 2FA App.'))
- code = forms.CharField(label=_('Code'), validators=[TFA_CODE_VALIDATOR])
+ label=_('Scan this Code with your TOTP App.'))
+ code = forms.CharField(label=_('Code'), validators=[TOTP_CODE_VALIDATOR])
def clean_code(self):
"""Check code with new totp device"""
if self.device is not None:
if not self.device.verify_token(int(self.cleaned_data.get('code'))) \
and not self.confirmed:
- raise forms.ValidationError(_("2FA Code does not match"))
+ raise forms.ValidationError(_("TOTP Code does not match"))
return self.cleaned_data.get('code')
-class TFASetupStaticForm(forms.Form):
+class TOTPSetupStaticForm(forms.Form):
"""Static form to show generated static tokens"""
tokens = forms.MultipleChoiceField(disabled=True, required=False)
diff --git a/passbook/tfa/middleware.py b/passbook/totp/middleware.py
similarity index 67%
rename from passbook/tfa/middleware.py
rename to passbook/totp/middleware.py
index 7b8ea1c09..88ebd32c3 100644
--- a/passbook/tfa/middleware.py
+++ b/passbook/totp/middleware.py
@@ -1,4 +1,4 @@
-"""passbook 2FA Middleware to force users with 2FA set up to verify"""
+"""passbook TOTP Middleware to force users with TOTP set up to verify"""
from django.shortcuts import redirect
from django.urls import reverse
@@ -6,24 +6,25 @@ from django.utils.http import urlencode
from django_otp import user_has_device
-def tfa_force_verify(get_response):
- """Middleware to force 2FA Verification"""
+def totp_force_verify(get_response):
+ """Middleware to force TOTP Verification"""
+
def middleware(request):
- """Middleware to force 2FA Verification"""
+ """Middleware to force TOTP Verification"""
# pylint: disable=too-many-boolean-expressions
if request.user.is_authenticated and \
user_has_device(request.user) and \
not request.user.is_verified() and \
- request.path != reverse('passbook_tfa:tfa-verify') and \
+ request.path != reverse('passbook_totp:totp-verify') and \
request.path != reverse('account-logout') and \
not request.META.get('HTTP_AUTHORIZATION', '').startswith('Bearer'):
- # User has 2FA set up but is not verified
+ # User has TOTP set up but is not verified
# At this point the request is already forwarded to the target destination
# So we just add the current request's path as next parameter
args = '?%s' % urlencode({'next': request.get_full_path()})
- return redirect(reverse('passbook_tfa:tfa-verify') + args)
+ return redirect(reverse('passbook_totp:totp-verify') + args)
response = get_response(request)
return response
diff --git a/passbook/tfa/requirements.txt b/passbook/totp/requirements.txt
similarity index 100%
rename from passbook/tfa/requirements.txt
rename to passbook/totp/requirements.txt
diff --git a/passbook/tfa/settings.py b/passbook/totp/settings.py
similarity index 90%
rename from passbook/tfa/settings.py
rename to passbook/totp/settings.py
index bc1bcae02..234a6f795 100644
--- a/passbook/tfa/settings.py
+++ b/passbook/totp/settings.py
@@ -1,4 +1,4 @@
-"""passbook 2FA Settings"""
+"""passbook TOTP Settings"""
OTP_LOGIN_URL = 'passbook_tfa:tfa-verify'
OTP_TOTP_ISSUER = 'passbook'
diff --git a/passbook/tfa/templates/tfa/user_settings.html b/passbook/totp/templates/totp/user_settings.html
similarity index 92%
rename from passbook/tfa/templates/tfa/user_settings.html
rename to passbook/totp/templates/totp/user_settings.html
index a0bfb0a7f..f9f92b5bb 100644
--- a/passbook/tfa/templates/tfa/user_settings.html
+++ b/passbook/totp/templates/totp/user_settings.html
@@ -31,9 +31,9 @@
{% if not state %} - {% trans "Enable 2FA" %} + {% trans "Enable TOTP" %} {% else %} - {% trans "Disable 2FA" %} + {% trans "Disable TOTP" %} {% endif %}
diff --git a/passbook/tfa/templates/tfa/wizard_setup_static.html b/passbook/totp/templates/totp/wizard_setup_static.html similarity index 89% rename from passbook/tfa/templates/tfa/wizard_setup_static.html rename to passbook/totp/templates/totp/wizard_setup_static.html index 19ab8efae..9282ee12b 100644 --- a/passbook/tfa/templates/tfa/wizard_setup_static.html +++ b/passbook/totp/templates/totp/wizard_setup_static.html @@ -7,7 +7,7 @@ {% endblock %} {% block form %} - + {% for field in wizard.form %} {% if field.field.widget|fieldtype == 'SelectMultiple' %}