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' %}
diff --git a/passbook/tfa/tests/__init__.py b/passbook/totp/tests/__init__.py
similarity index 100%
rename from passbook/tfa/tests/__init__.py
rename to passbook/totp/tests/__init__.py
diff --git a/passbook/tfa/tests/test_middleware.py b/passbook/totp/tests/test_middleware.py
similarity index 67%
rename from passbook/tfa/tests/test_middleware.py
rename to passbook/totp/tests/test_middleware.py
index e6313e77a..600bc2aeb 100644
--- a/passbook/tfa/tests/test_middleware.py
+++ b/passbook/totp/tests/test_middleware.py
@@ -1,4 +1,4 @@
-"""passbook Mod 2FA Middleware Test"""
+"""passbook TOTP Middleware Test"""
import os
@@ -7,19 +7,19 @@ from django.test import RequestFactory, TestCase
from django.urls import reverse
from passbook.core.views import overview
-from passbook.tfa.middleware import tfa_force_verify
+from passbook.totp.middleware import totp_force_verify
class TestMiddleware(TestCase):
- """passbook 2FA Middleware Test"""
+ """passbook TOTP Middleware Test"""
def setUp(self):
os.environ['RECAPTCHA_TESTING'] = 'True'
self.factory = RequestFactory()
- def test_tfa_force_verify_anon(self):
+ def test_totp_force_verify_anon(self):
"""Test Anonymous TFA Force"""
request = self.factory.get(reverse('passbook_core:overview'))
request.user = AnonymousUser()
- response = tfa_force_verify(overview.OverviewView.as_view())(request)
+ response = totp_force_verify(overview.OverviewView.as_view())(request)
self.assertEqual(response.status_code, 302)
diff --git a/passbook/totp/urls.py b/passbook/totp/urls.py
new file mode 100644
index 000000000..d2c036751
--- /dev/null
+++ b/passbook/totp/urls.py
@@ -0,0 +1,14 @@
+"""passbook TOTP Urls"""
+
+from django.urls import path
+
+from passbook.totp import views
+
+urlpatterns = [
+ path('', views.index, name='totp-index'),
+ path('qr/', views.qr_code, name='totp-qr'),
+ path('verify/', views.verify, name='totp-verify'),
+ # path('enable/', views.TFASetupView.as_view(), name='totp-enable'),
+ path('disable/', views.disable, name='totp-disable'),
+ path('user_settings/', views.user_settings, name='totp-user_settings'),
+]
diff --git a/passbook/tfa/utils.py b/passbook/totp/utils.py
similarity index 95%
rename from passbook/tfa/utils.py
rename to passbook/totp/utils.py
index 78bbd3f44..f3ca643c4 100644
--- a/passbook/tfa/utils.py
+++ b/passbook/totp/utils.py
@@ -1,4 +1,4 @@
-"""passbook Mod 2FA Utils"""
+"""passbook Mod TOTP Utils"""
from django.conf import settings
from django.utils.http import urlencode
diff --git a/passbook/tfa/views.py b/passbook/totp/views.py
similarity index 90%
rename from passbook/tfa/views.py
rename to passbook/totp/views.py
index 664675621..295bcf92f 100644
--- a/passbook/tfa/views.py
+++ b/passbook/totp/views.py
@@ -1,4 +1,4 @@
-"""passbook 2FA Views"""
+"""passbook TOTP Views"""
# from base64 import b32encode
# from binascii import unhexlify
@@ -19,8 +19,8 @@ from qrcode.image.svg import SvgPathImage
from passbook.lib.decorators import reauth_required
# from passbook.core.models import Event
# from passbook.core.views.wizards import BaseWizardView
-from passbook.tfa.forms import TFAVerifyForm
-from passbook.tfa.utils import otpauth_url
+from passbook.totp.forms import TOTPVerifyForm
+from passbook.totp.utils import otpauth_url
TFA_SESSION_KEY = 'passbook_2fa_key'
@@ -30,22 +30,22 @@ TFA_SESSION_KEY = 'passbook_2fa_key'
def index(request: HttpRequest) -> HttpResponse:
"""Show empty index page"""
return render(request, 'core/generic.html', {
- 'text': 'Test 2FA passed'
+ 'text': 'Test TOTP passed'
})
@login_required
def verify(request: HttpRequest) -> HttpResponse:
- """Verify 2FA Token"""
+ """Verify TOTP Token"""
if not user_has_device(request.user):
messages.error(request, _("You don't have 2-Factor Authentication set up."))
if request.method == 'POST':
- form = TFAVerifyForm(request.POST)
+ form = TOTPVerifyForm(request.POST)
if form.is_valid():
device = match_token(request.user, form.cleaned_data.get('code'))
if device:
login(request, device)
- messages.success(request, _('Successfully validated 2FA Token.'))
+ messages.success(request, _('Successfully validated TOTP Token.'))
# Check if there is a next GET parameter and redirect to that
if 'next' in request.GET:
return redirect(request.GET.get('next'))
@@ -53,7 +53,7 @@ def verify(request: HttpRequest) -> HttpResponse:
return redirect(reverse('common-index'))
messages.error(request, _('Invalid 2-Factor Token.'))
else:
- form = TFAVerifyForm()
+ form = TOTPVerifyForm()
return render(request, 'generic/form_login.html', {
'form': form,
@@ -67,13 +67,13 @@ def verify(request: HttpRequest) -> HttpResponse:
@login_required
def user_settings(request: HttpRequest) -> HttpResponse:
- """View for user settings to control 2FA"""
+ """View for user settings to control TOTP"""
static = get_object_or_404(StaticDevice, user=request.user, confirmed=True)
static_tokens = StaticToken.objects.filter(device=static).order_by('token')
finished_totp_devices = TOTPDevice.objects.filter(user=request.user, confirmed=True)
finished_static_devices = StaticDevice.objects.filter(user=request.user, confirmed=True)
state = finished_totp_devices.exists() and finished_static_devices.exists()
- return render(request, 'tfa/user_settings.html', {
+ return render(request, 'totp/user_settings.html', {
'static_tokens': static_tokens,
'state': state,
})
@@ -83,7 +83,7 @@ def user_settings(request: HttpRequest) -> HttpResponse:
@reauth_required
@otp_required
def disable(request: HttpRequest) -> HttpResponse:
- """Disable 2FA for user"""
+ """Disable TOTP for user"""
# Delete all the devices for user
static = get_object_or_404(StaticDevice, user=request.user, confirmed=True)
static_tokens = StaticToken.objects.filter(device=static).order_by('token')
@@ -92,11 +92,11 @@ def disable(request: HttpRequest) -> HttpResponse:
totp.delete()
for token in static_tokens:
token.delete()
- messages.success(request, 'Successfully disabled 2FA')
+ messages.success(request, 'Successfully disabled TOTP')
# Create event with email notification
# Event.create(
# user=request.user,
- # message=_('You disabled 2FA.'),
+ # message=_('You disabled TOTP.'),
# current=True,
# request=request,
# send_notification=True)
@@ -108,7 +108,7 @@ def disable(request: HttpRequest) -> HttpResponse:
# class TFASetupView(BaseWizardView):
# """Wizard to create a Mail Account"""
-# title = _('Set up 2FA')
+# title = _('Set up TOTP')
# form_list = [TFASetupInitForm, TFASetupStaticForm]
# totp_device = None
@@ -117,15 +117,15 @@ def disable(request: HttpRequest) -> HttpResponse:
# def get_template_names(self):
# if self.steps.current == '1':
-# return 'tfa/wizard_setup_static.html'
+# return 'totp/wizard_setup_static.html'
# return self.template_name
# def handle_request(self, request: HttpRequest):
-# # Check if user has 2FA setup already
+# # Check if user has TOTP setup already
# finished_totp_devices = TOTPDevice.objects.filter(user=request.user, confirmed=True)
# finished_static_devices = StaticDevice.objects.filter(user=request.user, confirmed=True)
# if finished_totp_devices.exists() or finished_static_devices.exists():
-# messages.error(request, _('You already have 2FA enabled!'))
+# messages.error(request, _('You already have TOTP enabled!'))
# return redirect(reverse('common-index'))
# # Check if there's an unconfirmed device left to set up
# totp_devices = TOTPDevice.objects.filter(user=request.user, confirmed=False)
@@ -182,7 +182,7 @@ def disable(request: HttpRequest) -> HttpResponse:
# # Create event with email notification
# Event.create(
# user=self.request.user,
-# message=_('You activated 2FA.'),
+# message=_('You activated TOTP.'),
# current=True,
# request=self.request,
# send_notification=True)