From 1b21b50b77de1f969630a6ee5dd7b165defa9800 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 27 Oct 2021 16:11:35 +0200 Subject: [PATCH] providers/oauth2: fallback to uid if UPN was selected but isn't available Signed-off-by: Jens Langhammer --- authentik/providers/oauth2/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/authentik/providers/oauth2/models.py b/authentik/providers/oauth2/models.py index 5fc9ea470..4dfd8e761 100644 --- a/authentik/providers/oauth2/models.py +++ b/authentik/providers/oauth2/models.py @@ -448,7 +448,7 @@ class RefreshToken(ExpiringModel, BaseGrantModel): elif self.provider.sub_mode == SubModes.USER_USERNAME: sub = user.username elif self.provider.sub_mode == SubModes.USER_UPN: - sub = user.attributes["upn"] + sub = user.attributes.get("upn", user.uid) else: raise ValueError( (