From c1fbdab06979fadf86a00fc81ebbbbefa44a85f3 Mon Sep 17 00:00:00 2001 From: Mohamed El-Kalioby Date: Fri, 28 May 2021 21:23:13 +0300 Subject: [PATCH] WIP: Passwordless --- example/example/auth.py | 6 ++- example/example/templates/login.html | 13 ++--- mfa/FIDO2.py | 7 +-- mfa/templates/FIDO2/fido2_auth.html | 71 +++++++++++++++++++++++++++ mfa/templates/FIDO2/login.html | 1 + mfa/templates/FIDO2/recheck.html | 73 +--------------------------- setup.py | 2 +- 7 files changed, 87 insertions(+), 86 deletions(-) create mode 100644 mfa/templates/FIDO2/fido2_auth.html create mode 100644 mfa/templates/FIDO2/login.html diff --git a/example/example/auth.py b/example/example/auth.py index afd587b..d1baff3 100644 --- a/example/example/auth.py +++ b/example/example/auth.py @@ -27,4 +27,8 @@ def create_session(request,username): def logoutView(request): logout(request) - return render(request,"logout.html",{}) \ No newline at end of file + return render(request,"logout.html",{}) + +def register(request): + if request.method == "GET": + return \ No newline at end of file diff --git a/example/example/templates/login.html b/example/example/templates/login.html index 139c77f..554f9ff 100644 --- a/example/example/templates/login.html +++ b/example/example/templates/login.html @@ -17,7 +17,6 @@ - @@ -29,7 +28,6 @@ {% if invalid %}
Invalid Username or password
{% endif %} -
{% csrf_token %}
@@ -37,14 +35,9 @@
-
-
- - -
-
- + +
@@ -56,7 +49,7 @@ - +{% include 'FIDO2/login.html' %} diff --git a/mfa/FIDO2.py b/mfa/FIDO2.py index 98a6e5e..5aeb465 100644 --- a/mfa/FIDO2.py +++ b/mfa/FIDO2.py @@ -80,6 +80,7 @@ def start(request): """Start Registeration a new FIDO Token""" context = csrf(request) context.update(get_redirect_url()) + context["mfa_invoke"] = True return render(request, "FIDO2/Add.html", context) @@ -97,8 +98,8 @@ def auth(request): def authenticate_begin(request): server = getServer() - credentials = getUserCredentials(request.session.get("base_username", request.user.username)) - auth_data, state = server.authenticate_begin(credentials) + #credentials = getUserCredentials(request.session.get("base_username", request.user.username)) + auth_data, state = server.authenticate_begin() request.session['fido_state'] = state return HttpResponse(cbor.encode(auth_data), content_type = "application/octet-stream") @@ -107,7 +108,7 @@ def authenticate_begin(request): def authenticate_complete(request): try: credentials = [] - username = request.session.get("base_username", request.user.username) + username = request.session.get("base_username", request.POST.get("username",request.user.username)) server = getServer() credentials = getUserCredentials(username) data = cbor.decode(request.body) diff --git a/mfa/templates/FIDO2/fido2_auth.html b/mfa/templates/FIDO2/fido2_auth.html new file mode 100644 index 0000000..343e736 --- /dev/null +++ b/mfa/templates/FIDO2/fido2_auth.html @@ -0,0 +1,71 @@ +{% load static %} + + + + \ No newline at end of file diff --git a/mfa/templates/FIDO2/login.html b/mfa/templates/FIDO2/login.html new file mode 100644 index 0000000..ae0cf7e --- /dev/null +++ b/mfa/templates/FIDO2/login.html @@ -0,0 +1 @@ +{% include 'FIDO2/fido2_auth.html' %} \ No newline at end of file diff --git a/mfa/templates/FIDO2/recheck.html b/mfa/templates/FIDO2/recheck.html index 3dc0609..e65fc25 100644 --- a/mfa/templates/FIDO2/recheck.html +++ b/mfa/templates/FIDO2/recheck.html @@ -1,6 +1,4 @@ -{% load static %} - - +
@@ -47,71 +45,4 @@
- \ No newline at end of file +{% include 'FIDO2/fido2_auth.html' %} \ No newline at end of file diff --git a/setup.py b/setup.py index 8958ee5..9de183f 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import find_packages, setup setup( name='django-mfa2', - version='2.2.0b1', + version='2.2.0b2 ', description='Allows user to add 2FA to their accounts', long_description=open("README.md").read(), long_description_content_type="text/markdown",