From a9967c9a4dc21f67e882ff9b02bb5e9bfa8ebd63 Mon Sep 17 00:00:00 2001 From: devStorm <59678453+developStorm@users.noreply.github.com> Date: Mon, 11 May 2020 19:17:51 -0700 Subject: [PATCH] Auto activate WebAuthn authentication --- app/auth/templates/auth/fido.html | 4 ++++ app/auth/views/fido.py | 3 +++ server.py | 1 + 3 files changed, 8 insertions(+) diff --git a/app/auth/templates/auth/fido.html b/app/auth/templates/auth/fido.html index 0d8c0305..34d67078 100644 --- a/app/auth/templates/auth/fido.html +++ b/app/auth/templates/auth/fido.html @@ -62,6 +62,10 @@ $("#btnVerifyKey").click(verifyKey); + {% if auto_activate %} + + {% endif %} + diff --git a/app/auth/views/fido.py b/app/auth/views/fido.py index d145f916..ae1ba200 100644 --- a/app/auth/views/fido.py +++ b/app/auth/views/fido.py @@ -35,6 +35,7 @@ def fido(): flash("Only user with security key linked should go to this page", "warning") return redirect(url_for("auth.login")) + auto_activate = True fido_token_form = FidoTokenForm() next_url = request.args.get("next") @@ -69,6 +70,7 @@ def fido(): except Exception as e: LOG.error(f"An error occurred in WebAuthn verification process: {e}") flash("Key verification failed.", "warning") + auto_activate = False else: user.fido_sign_count = new_sign_count db.session.commit() @@ -101,4 +103,5 @@ def fido(): fido_token_form=fido_token_form, webauthn_assertion_options=webauthn_assertion_options, enable_otp=user.enable_otp, + auto_activate=auto_activate, ) diff --git a/server.py b/server.py index f20799fc..70b5e0c3 100644 --- a/server.py +++ b/server.py @@ -136,6 +136,7 @@ def fake_data(): activated=True, is_admin=True, otp_secret="base32secret3232", + can_use_fido=True, ) db.session.commit() user.trial_end = None