From 26fd66d83114f19446e47a07cedab0b29b6c2f62 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 1 Sep 2021 19:54:54 +0200 Subject: [PATCH] stages/authenticator_validate: fix variable shadowing, optimization Signed-off-by: Jens Langhammer --- .../authenticator_validate/challenge.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/authentik/stages/authenticator_validate/challenge.py b/authentik/stages/authenticator_validate/challenge.py index 49213e69e..d35df56b1 100644 --- a/authentik/stages/authenticator_validate/challenge.py +++ b/authentik/stages/authenticator_validate/challenge.py @@ -52,18 +52,19 @@ def get_webauthn_challenge(request: HttpRequest, device: WebAuthnDevice) -> dict request.session["challenge"] = challenge.rstrip("=") assertion = {} + user = device.user # We want all the user's WebAuthn devices and merge their challenges - for device in WebAuthnDevice.objects.filter(user=device.user).order_by("name"): + for user_device in WebAuthnDevice.objects.filter(user=device.user).order_by("name"): webauthn_user = WebAuthnUser( - device.user.uid, - device.user.username, - device.user.name, - device.user.avatar, - device.credential_id, - device.public_key, - device.sign_count, - device.rp_id, + user.uid, + user.username, + user.name, + user.avatar, + user_device.credential_id, + user_device.public_key, + user_device.sign_count, + user_device.rp_id, ) webauthn_assertion_options = WebAuthnAssertionOptions(webauthn_user, challenge) if assertion == {}: