forked from GithubBackups/healthchecks
Rename login_tfa to login_webauthn
This commit is contained in:
parent
7639f0dd69
commit
adb7702f39
@ -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()
|
||||
|
@ -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/")
|
||||
|
@ -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"}
|
||||
|
@ -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()
|
||||
|
@ -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"),
|
||||
|
@ -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)
|
||||
|
@ -59,7 +59,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-{{ tfa_status }}">
|
||||
<div class="panel panel-{{ 2fa_status }}">
|
||||
<div class="panel-body settings-block">
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user