From 535f94b0316e92818cf87ef0d961420ba7dfef7d Mon Sep 17 00:00:00 2001 From: Chris McIntosh Date: Fri, 21 May 2021 15:26:49 -0500 Subject: [PATCH 1/9] Adding the compare attribute to let teams compare on email address --- .env.example.aad | 4 ++++ .env.example.ldap | 3 +++ .env.example.okta | 4 ++++ .env.example.onelogin | 4 ++++ README.md | 4 ++-- app.py | 13 ++++++++++--- githubapp/__init__.py | 1 + 7 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.env.example.aad b/.env.example.aad index ff22994..4302220 100644 --- a/.env.example.aad +++ b/.env.example.aad @@ -16,6 +16,10 @@ PRIVATE_KEY_PATH=.ssh/team-sync.pem ## Active Directory = LDAP ## OpenLDAP = LDAP USER_DIRECTORY=AAD +## Attribute to compare users with +## username or email +USER_ATTRIBUTE=username + ####################### ## Azure AD Settings ## diff --git a/.env.example.ldap b/.env.example.ldap index 10d3c80..5b39eaa 100644 --- a/.env.example.ldap +++ b/.env.example.ldap @@ -16,6 +16,9 @@ PRIVATE_KEY_PATH=.ssh/team-sync.pem ## Active Directory = LDAP ## OpenLDAP = LDAP USER_DIRECTORY=LDAP +## Attribute to compare users with +## username or email +USER_ATTRIBUTE=username ################### ## LDAP Settings ## diff --git a/.env.example.okta b/.env.example.okta index 80874c8..410b979 100644 --- a/.env.example.okta +++ b/.env.example.okta @@ -17,6 +17,10 @@ PRIVATE_KEY_PATH=.ssh/team-sync.pem ## OpenLDAP = LDAP ## Okta = OKTA USER_DIRECTORY=OKTA +## Attribute to compare users with +## username or email +USER_ATTRIBUTE=username + ################### ## Okta Settings ## diff --git a/.env.example.onelogin b/.env.example.onelogin index e52ddff..7bfdccc 100644 --- a/.env.example.onelogin +++ b/.env.example.onelogin @@ -18,6 +18,10 @@ PRIVATE_KEY_PATH=.ssh/team-sync.pem ## Okta = OKTA ## OneLogin = ONELOGIN USER_DIRECTORY=ONELOGIN +## Attribute to compare users with +## username or email +USER_ATTRIBUTE=username + ####################### ## OneLogin Settings ## diff --git a/README.md b/README.md index 08a4cdd..796b10a 100644 --- a/README.md +++ b/README.md @@ -48,10 +48,10 @@ This utility provides the following functionality: | Category | Attribute | Permission | | --- | --- | --- | +| Repository permissions | `Issues` | `Read & write` | +| Repositroy permissions | `Metadata` | `Read-only` | | Organization permissions | `Members` | `Read & write` | | User permissions | `Email addresses` | `Read-only` | -| Repository permissions | `Issues` | `Read & write` | -| Repostiroy permissions | `Metadata` | `Read-only` | #### Events diff --git a/app.py b/app.py index 205fd0c..da7c6f7 100644 --- a/app.py +++ b/app.py @@ -9,7 +9,14 @@ from apscheduler.triggers.cron import CronTrigger from flask import Flask -from githubapp import GitHubApp, DirectoryClient, CRON_INTERVAL, TEST_MODE, ADD_MEMBER +from githubapp import ( + GitHubApp, + DirectoryClient, + CRON_INTERVAL, + TEST_MODE, + ADD_MEMBER, + COMPARE_ATTRIBUTE, +) app = Flask(__name__) github_app = GitHubApp(app) @@ -59,10 +66,10 @@ def sync_team(client=None, owner=None, team_id=None, slug=None): directory_members = [] print(e) team_members = github_team_members( - client=client, owner=owner, team_id=team_id, attribute="username" + client=client, owner=owner, team_id=team_id, attribute=COMPARE_ATTRIBUTE ) compare = compare_members( - group=directory_members, team=team_members, attribute="username" + group=directory_members, team=team_members, attribute=COMPARE_ATTRIBUTE ) if TEST_MODE: print("Skipping execution due to TEST_MODE...") diff --git a/githubapp/__init__.py b/githubapp/__init__.py index eef1eca..7c8a4a4 100644 --- a/githubapp/__init__.py +++ b/githubapp/__init__.py @@ -39,3 +39,4 @@ TEST_MODE = False # Check if should add member to organization ADD_MEMBER = strtobool(os.environ.get("ADD_MEMBER", "False")) +COMPARE_ATTRIBUTE = os.environ.get("COMPARE_ATTRIBUTE", "username").lower() From 778eb9eaf6c97ad21255d0b22814942a34ff0d6e Mon Sep 17 00:00:00 2001 From: Chris McIntosh Date: Tue, 25 May 2021 08:29:12 -0500 Subject: [PATCH 2/9] Update .env.example.aad Co-authored-by: Jared Murrell --- .env.example.aad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example.aad b/.env.example.aad index 4302220..cc929de 100644 --- a/.env.example.aad +++ b/.env.example.aad @@ -18,7 +18,7 @@ PRIVATE_KEY_PATH=.ssh/team-sync.pem USER_DIRECTORY=AAD ## Attribute to compare users with ## username or email -USER_ATTRIBUTE=username +USER_SYNC_ATTRIBUTE=username ####################### From 94c5c4e16d6e3efa8995238280bb4138cd4b2008 Mon Sep 17 00:00:00 2001 From: Chris McIntosh Date: Tue, 25 May 2021 08:29:17 -0500 Subject: [PATCH 3/9] Update .env.example.okta Co-authored-by: Jared Murrell --- .env.example.okta | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example.okta b/.env.example.okta index 410b979..f3e112e 100644 --- a/.env.example.okta +++ b/.env.example.okta @@ -19,7 +19,7 @@ PRIVATE_KEY_PATH=.ssh/team-sync.pem USER_DIRECTORY=OKTA ## Attribute to compare users with ## username or email -USER_ATTRIBUTE=username +USER_SYNC_ATTRIBUTE=username ################### From 54661a9b8c92d0b1645895c7cf76686d3961e3e4 Mon Sep 17 00:00:00 2001 From: Chris McIntosh Date: Tue, 25 May 2021 08:29:22 -0500 Subject: [PATCH 4/9] Update .env.example.ldap Co-authored-by: Jared Murrell --- .env.example.ldap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example.ldap b/.env.example.ldap index 5b39eaa..8b24242 100644 --- a/.env.example.ldap +++ b/.env.example.ldap @@ -18,7 +18,7 @@ PRIVATE_KEY_PATH=.ssh/team-sync.pem USER_DIRECTORY=LDAP ## Attribute to compare users with ## username or email -USER_ATTRIBUTE=username +USER_SYNC_ATTRIBUTE=username ################### ## LDAP Settings ## From 4a06a13c759904654b1cdf8430f89cc88d477352 Mon Sep 17 00:00:00 2001 From: Chris McIntosh Date: Tue, 25 May 2021 08:29:28 -0500 Subject: [PATCH 5/9] Update app.py Co-authored-by: Jared Murrell --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index da7c6f7..1657bb6 100644 --- a/app.py +++ b/app.py @@ -15,7 +15,7 @@ CRON_INTERVAL, TEST_MODE, ADD_MEMBER, - COMPARE_ATTRIBUTE, + USER_SYNC_ATTRIBUTE, ) app = Flask(__name__) From 6826f69357f38c22cc0649fcd31c58fc6486172f Mon Sep 17 00:00:00 2001 From: Chris McIntosh Date: Tue, 25 May 2021 08:29:35 -0500 Subject: [PATCH 6/9] Update app.py Co-authored-by: Jared Murrell --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index 1657bb6..e802d85 100644 --- a/app.py +++ b/app.py @@ -66,7 +66,7 @@ def sync_team(client=None, owner=None, team_id=None, slug=None): directory_members = [] print(e) team_members = github_team_members( - client=client, owner=owner, team_id=team_id, attribute=COMPARE_ATTRIBUTE + client=client, owner=owner, team_id=team_id, attribute=USER_SYNC_ATTRIBUTE ) compare = compare_members( group=directory_members, team=team_members, attribute=COMPARE_ATTRIBUTE From 2df6736c4ca4fbe5cf5b0c1052c60f8ea6cb876a Mon Sep 17 00:00:00 2001 From: Chris McIntosh Date: Tue, 25 May 2021 08:29:39 -0500 Subject: [PATCH 7/9] Update githubapp/__init__.py Co-authored-by: Jared Murrell --- githubapp/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/githubapp/__init__.py b/githubapp/__init__.py index 7c8a4a4..3a3cf5c 100644 --- a/githubapp/__init__.py +++ b/githubapp/__init__.py @@ -39,4 +39,4 @@ TEST_MODE = False # Check if should add member to organization ADD_MEMBER = strtobool(os.environ.get("ADD_MEMBER", "False")) -COMPARE_ATTRIBUTE = os.environ.get("COMPARE_ATTRIBUTE", "username").lower() +USER_SYNC_ATTRIBUTE = os.environ.get("USER_SYNC_ATTRIBUTE", "username").lower() From fb0824b3b945262b2c1ec1d6eceef884a3ed1948 Mon Sep 17 00:00:00 2001 From: Chris McIntosh Date: Tue, 25 May 2021 08:29:47 -0500 Subject: [PATCH 8/9] Update app.py Co-authored-by: Jared Murrell --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index e802d85..7ae8579 100644 --- a/app.py +++ b/app.py @@ -69,7 +69,7 @@ def sync_team(client=None, owner=None, team_id=None, slug=None): client=client, owner=owner, team_id=team_id, attribute=USER_SYNC_ATTRIBUTE ) compare = compare_members( - group=directory_members, team=team_members, attribute=COMPARE_ATTRIBUTE + group=directory_members, team=team_members, attribute=USER_SYNC_ATTRIBUTE ) if TEST_MODE: print("Skipping execution due to TEST_MODE...") From 470205a9402ab56ad5d06e675eda250b74c54c9b Mon Sep 17 00:00:00 2001 From: Chris McIntosh Date: Tue, 25 May 2021 08:29:55 -0500 Subject: [PATCH 9/9] Update .env.example.onelogin Co-authored-by: Jared Murrell --- .env.example.onelogin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example.onelogin b/.env.example.onelogin index 7bfdccc..771ef43 100644 --- a/.env.example.onelogin +++ b/.env.example.onelogin @@ -20,7 +20,7 @@ PRIVATE_KEY_PATH=.ssh/team-sync.pem USER_DIRECTORY=ONELOGIN ## Attribute to compare users with ## username or email -USER_ATTRIBUTE=username +USER_SYNC_ATTRIBUTE=username #######################