From ee1739fc591bc87811ad92c08ad69b0a4ca47577 Mon Sep 17 00:00:00 2001 From: KonPaw Date: Tue, 26 Sep 2023 06:46:55 +0200 Subject: [PATCH 1/2] Add AAD username normalization --- githubapp/azuread.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/githubapp/azuread.py b/githubapp/azuread.py index a77e14e..51f4ed0 100644 --- a/githubapp/azuread.py +++ b/githubapp/azuread.py @@ -107,7 +107,11 @@ def get_group_members(self, token=None, group_name=None): else: username = user_info[self.USERNAME_ATTRIBUTE] if self.AZURE_USER_IS_UPN: - username = username.split("@")[0] + if r"\\" in username: + username = username.split(r"\\")[1] + username = username.split("@")[0].split("#")[0].split("_")[0] + username = username.translate(str.maketrans("._!#^~", '------')) + username = username.lower() if "EMU_SHORTCODE" in os.environ: username = username + "_" + os.environ["EMU_SHORTCODE"] user = { From 985bd99e8178004108ad9440dda2631055b9ce15 Mon Sep 17 00:00:00 2001 From: KonPaw Date: Thu, 28 Sep 2023 19:59:23 +0200 Subject: [PATCH 2/2] Fix formatting --- githubapp/azuread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/githubapp/azuread.py b/githubapp/azuread.py index 51f4ed0..651ac47 100644 --- a/githubapp/azuread.py +++ b/githubapp/azuread.py @@ -110,7 +110,7 @@ def get_group_members(self, token=None, group_name=None): if r"\\" in username: username = username.split(r"\\")[1] username = username.split("@")[0].split("#")[0].split("_")[0] - username = username.translate(str.maketrans("._!#^~", '------')) + username = username.translate(str.maketrans("._!#^~", "------")) username = username.lower() if "EMU_SHORTCODE" in os.environ: username = username + "_" + os.environ["EMU_SHORTCODE"]