diff --git a/hc/accounts/forms.py b/hc/accounts/forms.py index a03443f7..3718e5f6 100644 --- a/hc/accounts/forms.py +++ b/hc/accounts/forms.py @@ -135,7 +135,7 @@ class AddCredentialForm(forms.Form): attestation_object = Base64Field() -class LoginTfaForm(forms.Form): +class WebauthnForm(forms.Form): credential_id = Base64Field() client_data_json = Base64Field() authenticator_data = Base64Field() diff --git a/hc/accounts/tests/test_check_token.py b/hc/accounts/tests/test_check_token.py index a5f1a465..4de17e91 100644 --- a/hc/accounts/tests/test_check_token.py +++ b/hc/accounts/tests/test_check_token.py @@ -50,7 +50,7 @@ class CheckTokenTestCase(BaseTestCase): r = self.client.post(url) self.assertRedirects(r, self.checks_url) - def test_it_redirects_to_login_tfa(self): + def test_it_redirects_to_webauthn_form(self): Credential.objects.create(user=self.alice, name="Alices Key") r = self.client.post("/accounts/check_token/alice/secret-token/") diff --git a/hc/accounts/tests/test_login.py b/hc/accounts/tests/test_login.py index 277d8425..99cd86e5 100644 --- a/hc/accounts/tests/test_login.py +++ b/hc/accounts/tests/test_login.py @@ -113,7 +113,7 @@ class LoginTestCase(BaseTestCase): r = self.client.get("/accounts/login/") self.assertNotContains(r, "Create Your Account") - def test_it_redirects_to_login_tfa(self): + def test_it_redirects_to_webauthn_form(self): Credential.objects.create(user=self.alice, name="Alices Key") form = {"action": "login", "email": "alice@example.org", "password": "password"} diff --git a/hc/accounts/tests/test_login_tfa.py b/hc/accounts/tests/test_login_webauthn.py similarity index 98% rename from hc/accounts/tests/test_login_tfa.py rename to hc/accounts/tests/test_login_webauthn.py index d162793c..662d0780 100644 --- a/hc/accounts/tests/test_login_tfa.py +++ b/hc/accounts/tests/test_login_webauthn.py @@ -3,7 +3,7 @@ from unittest.mock import patch from hc.test import BaseTestCase -class LoginTfaTestCase(BaseTestCase): +class LoginWebauthnTestCase(BaseTestCase): def setUp(self): super().setUp() diff --git a/hc/accounts/urls.py b/hc/accounts/urls.py index b96d1986..35e8b2e5 100644 --- a/hc/accounts/urls.py +++ b/hc/accounts/urls.py @@ -3,7 +3,7 @@ from hc.accounts import views urlpatterns = [ path("login/", views.login, name="hc-login"), - path("login/two_factor/", views.login_tfa, name="hc-login-tfa"), + path("login/two_factor/", views.login_webauthn, name="hc-login-webauthn"), path("logout/", views.logout, name="hc-logout"), path("signup/", views.signup, name="hc-signup"), path("login_link_sent/", views.login_link_sent, name="hc-login-link-sent"), diff --git a/hc/accounts/views.py b/hc/accounts/views.py index 41c682c8..ca45e9df 100644 --- a/hc/accounts/views.py +++ b/hc/accounts/views.py @@ -105,7 +105,7 @@ def _check_2fa(request, user): if user.credentials.exists(): request.session["2fa_user_id"] = user.id - path = reverse("hc-login-tfa") + path = reverse("hc-login-webauthn") redirect_url = request.GET.get("next") if _allow_redirect(redirect_url): path += "?next=%s" % redirect_url @@ -223,17 +223,17 @@ def profile(request): "page": "profile", "profile": profile, "my_projects_status": "default", - "tfa_status": "default", + "2fa_status": "default", "added_credential_name": request.session.pop("added_credential_name", ""), "removed_credential_name": request.session.pop("removed_credential_name", ""), "credentials": request.user.credentials.order_by("id"), } if ctx["added_credential_name"]: - ctx["tfa_status"] = "success" + ctx["2fa_status"] = "success" if ctx["removed_credential_name"]: - ctx["tfa_status"] = "info" + ctx["2fa_status"] = "info" if request.method == "POST": if "change_email" in request.POST: @@ -670,7 +670,7 @@ def _check_credential(request, form, credentials): return True -def login_tfa(request): +def login_webauthn(request): if "2fa_user_id" not in request.session: return HttpResponseBadRequest() @@ -678,7 +678,7 @@ def login_tfa(request): credentials = [c.unpack() for c in user.credentials.all()] if request.method == "POST": - form = forms.LoginTfaForm(request.POST) + form = forms.WebauthnForm(request.POST) if not form.is_valid(): return HttpResponseBadRequest() @@ -694,4 +694,4 @@ def login_tfa(request): request.session["state"] = state ctx = {"options": base64.b64encode(cbor.encode(options)).decode()} - return render(request, "accounts/login_tfa.html", ctx) + return render(request, "accounts/login_webauthn.html", ctx) diff --git a/templates/accounts/login_tfa.html b/templates/accounts/login_webauthn.html similarity index 100% rename from templates/accounts/login_tfa.html rename to templates/accounts/login_webauthn.html diff --git a/templates/accounts/profile.html b/templates/accounts/profile.html index ae5336a6..b842b035 100644 --- a/templates/accounts/profile.html +++ b/templates/accounts/profile.html @@ -59,7 +59,7 @@ -
+
{% csrf_token %}