diff --git a/.env.example.aad b/.env.example.aad index ff22994..cc929de 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_SYNC_ATTRIBUTE=username + ####################### ## Azure AD Settings ## diff --git a/.env.example.ldap b/.env.example.ldap index 10d3c80..8b24242 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_SYNC_ATTRIBUTE=username ################### ## LDAP Settings ## diff --git a/.env.example.okta b/.env.example.okta index 80874c8..f3e112e 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_SYNC_ATTRIBUTE=username + ################### ## Okta Settings ## diff --git a/.env.example.onelogin b/.env.example.onelogin index e52ddff..771ef43 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_SYNC_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..7ae8579 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, + USER_SYNC_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=USER_SYNC_ATTRIBUTE ) compare = compare_members( - group=directory_members, team=team_members, attribute="username" + group=directory_members, team=team_members, attribute=USER_SYNC_ATTRIBUTE ) if TEST_MODE: print("Skipping execution due to TEST_MODE...") diff --git a/githubapp/__init__.py b/githubapp/__init__.py index eef1eca..3a3cf5c 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")) +USER_SYNC_ATTRIBUTE = os.environ.get("USER_SYNC_ATTRIBUTE", "username").lower()