From ee1739fc591bc87811ad92c08ad69b0a4ca47577 Mon Sep 17 00:00:00 2001 From: KonPaw Date: Tue, 26 Sep 2023 06:46:55 +0200 Subject: [PATCH 1/5] 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 f2ffb672aaa0056df33754c9b92a91df973c4886 Mon Sep 17 00:00:00 2001 From: Cat from Catalyst Date: Thu, 28 Sep 2023 14:32:45 +0100 Subject: [PATCH 2/5] Update app.py empty list has no .length() but len([]) is 0 --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index dedc9fd..96df09c 100644 --- a/app.py +++ b/app.py @@ -70,7 +70,7 @@ def sync_team(client=None, owner=None, team_id=None, slug=None): try: directory_group = get_directory_from_slug(slug, custom_map, org) # If we're filtering on group prefix, skip if the group doesn't match - if group_prefix.length() > 0 and not directory_group.startswith( + if len(group_prefix) > 0 and not directory_group.startswith( tuple(group_prefix) ): print(f"skipping team {team.slug} - not in group prefix") From 985bd99e8178004108ad9440dda2631055b9ce15 Mon Sep 17 00:00:00 2001 From: KonPaw Date: Thu, 28 Sep 2023 19:59:23 +0200 Subject: [PATCH 3/5] 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"] From e275f0a2d8fed0a80f99bd82633ea81d062a2583 Mon Sep 17 00:00:00 2001 From: Cat from Catalyst Date: Mon, 2 Oct 2023 09:59:03 +0100 Subject: [PATCH 4/5] Add a health check endpoint Some deployment systems require a health check --- githubapp/core.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/githubapp/core.py b/githubapp/core.py index 07fced3..e6ff8dc 100644 --- a/githubapp/core.py +++ b/githubapp/core.py @@ -89,6 +89,11 @@ def init_app(self, app): methods=["POST"], ) + app.add_url_rule("/health_check", endpoint="health_check") + @app.endpoint("health_check") + def health_check(): + return 'Web server is running.', 200 + @property def id(self): return current_app.config["GITHUBAPP_ID"] From cf361b95dff845aaf914c33ffbbf3de668802bda Mon Sep 17 00:00:00 2001 From: Cat from Catalyst Date: Mon, 2 Oct 2023 10:07:43 +0100 Subject: [PATCH 5/5] Fix for formatting --- githubapp/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/githubapp/core.py b/githubapp/core.py index e6ff8dc..2684192 100644 --- a/githubapp/core.py +++ b/githubapp/core.py @@ -92,7 +92,7 @@ def init_app(self, app): app.add_url_rule("/health_check", endpoint="health_check") @app.endpoint("health_check") def health_check(): - return 'Web server is running.', 200 + return "Web server is running.", 200 @property def id(self):