From ceb894039e64727ac288b648d9068ecb7d6dbcbe Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 14 Mar 2022 21:15:22 +0100 Subject: [PATCH] stages/authenticator_validate: fix passwordless flows not working closes #2484 Signed-off-by: Jens Langhammer --- Makefile | 3 +-- authentik/core/models.py | 2 +- authentik/stages/authenticator_validate/stage.py | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index cf0bf384a..9432eea18 100644 --- a/Makefile +++ b/Makefile @@ -137,7 +137,6 @@ install: cd website && npm i a: install - tmux \ + tmux -CC \ new-session 'make run' \; \ split-window 'make web-watch' - # detach-client diff --git a/authentik/core/models.py b/authentik/core/models.py index 4bc228059..284ca3b17 100644 --- a/authentik/core/models.py +++ b/authentik/core/models.py @@ -291,7 +291,7 @@ class Application(PolicyBindingModel): url = self.meta_launch_url if provider := self.get_provider(): url = provider.launch_url - if user: + if user and url: if isinstance(user, SimpleLazyObject): user._setup() user = user._wrapped diff --git a/authentik/stages/authenticator_validate/stage.py b/authentik/stages/authenticator_validate/stage.py index 2308fcbb0..40294be04 100644 --- a/authentik/stages/authenticator_validate/stage.py +++ b/authentik/stages/authenticator_validate/stage.py @@ -1,4 +1,5 @@ """Authenticator Validation""" +from django.contrib.auth.models import AnonymousUser from django.http import HttpRequest, HttpResponse from django_otp import devices_for_user from rest_framework.fields import CharField, IntegerField, JSONField, ListField, UUIDField @@ -279,7 +280,7 @@ class AuthenticatorValidateStageView(ChallengeStageView): def challenge_valid(self, response: AuthenticatorValidationChallengeResponse) -> HttpResponse: # All validation is done by the serializer user = self.executor.plan.context.get(PLAN_CONTEXT_PENDING_USER) - if not user: + if not user or isinstance(user, AnonymousUser): webauthn_device: WebAuthnDevice = response.data.get("webauthn", None) if not webauthn_device: return self.executor.stage_ok()