Skip to content

Commit

Permalink
Merge pull request #82 from github/c/email-compare
Browse files Browse the repository at this point in the history
Adding the compare attribute to let teams compare on email address
  • Loading branch information
Chris McIntosh authored May 25, 2021
2 parents ff290cc + 470205a commit 2f31752
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .env.example.aad
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##
Expand Down
3 changes: 3 additions & 0 deletions .env.example.ldap
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##
Expand Down
4 changes: 4 additions & 0 deletions .env.example.okta
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##
Expand Down
4 changes: 4 additions & 0 deletions .env.example.onelogin
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 10 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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...")
Expand Down
1 change: 1 addition & 0 deletions githubapp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 2f31752

Please sign in to comment.