Skip to content

Commit

Permalink
fixing markdown linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
primetheus committed Mar 24, 2021
1 parent 3d7262a commit ca1eae6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
9 changes: 9 additions & 0 deletions .env.example.aad
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ AZURE_APP_SCOPE=".default"
AZURE_API_ENDPOINT="https://graph.microsoft.com/v1.0"
## Custom attribute for usernames
AZURE_USERNAME_ATTRIBUTE=userPrincipalName
## If we don't have a custom username attribute, we'll
## need to make sure the username matches what's in
## GitHub. This will take the UPN and split the
## string on "@", making [email protected] just "user"
## in order to match GitHub.
## This should not be necessary if you add a new
## attribute for user mapping
## Default: false
#AZURE_USER_IS_UPN=true

#########################
## Additional settings ##
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# GitHub Team Sync
This utility is intended to enable synchronization between GitHub and various LDAP and SAML providers.
This is particularly useful for large organizations with many teams that either use GitHub Enterprise Cloud,
This is particularly useful for large organizations with many teams that either use GitHub Enterprise Cloud,
do not use LDAP for authentication, or use a SAML provider other than what is natively supported.
It supports both GitHub.com, GitHub Enterprise Server (GHES) and GitHub , but it will need to live in a location that can access your LDAP servers.

Expand Down Expand Up @@ -157,6 +157,7 @@ AZURE_CLIENT_SECRET="<client_secret>"
AZURE_APP_SCOPE="default"
AZURE_API_ENDPOINT="https://graph.microsoft.com/v1.0"
AZURE_USERNAME_ATTRIBUTE=userPrincipalName
AZURE_USER_IS_UPN=true
```

### Sample `.env` for Okta
Expand Down
25 changes: 18 additions & 7 deletions githubapp/azuread.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import json
import logging

from distutils.util import strtobool
import requests
import msal

Expand All @@ -21,8 +21,13 @@ def __init__(self):
f"https://graph.microsoft.com/{x}"
for x in os.environ["AZURE_APP_SCOPE"].split(" ")
]
self.AZURE_API_ENDPOINT = os.environ["AZURE_API_ENDPOINT"]
self.USERNAME_ATTRIBUTE = os.environ["AZURE_USERNAME_ATTRIBUTE"]
self.AZURE_API_ENDPOINT = os.environ.get(
"AZURE_API_ENDPOINT", "https://graph.microsoft.com/v1.0"
)
self.USERNAME_ATTRIBUTE = os.environ.get(
"AZURE_USERNAME_ATTRIBUTE", "userPrincipalName"
)
self.AZURE_USER_IS_UPN = strtobool(os.environ.get("AZURE_USER_IS_UPN", "False"))

def get_access_token(self):
"""
Expand Down Expand Up @@ -77,10 +82,16 @@ def get_group_members(self, token=None, group_name=None):
).json()["value"]
for member in members:
user_info = self.get_user_info(token=token, user=member["id"])
user = {
"username": user_info[self.USERNAME_ATTRIBUTE],
"email": user_info["mail"],
}
if self.AZURE_USER_IS_UPN:
user = {
"username": user_info[self.USERNAME_ATTRIBUTE].split("@")[0],
"email": user_info["mail"],
}
else:
user = {
"username": user_info[self.USERNAME_ATTRIBUTE],
"email": user_info["mail"],
}
member_list.append(user)
return member_list

Expand Down
6 changes: 1 addition & 5 deletions githubapp/onelogin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ def __init__(self):
CLIENT_ID = os.environ["ONELOGIN_CLIENT_ID"]
CLIENT_SECRET = os.environ["ONELOGIN_CLIENT_SECRET"]
REGION = os.environ.get("ONELOGIN_REGION", "US").upper()
self.client = OneLoginClient(
CLIENT_ID,
CLIENT_SECRET,
REGION
)
self.client = OneLoginClient(CLIENT_ID, CLIENT_SECRET, REGION)

def get_group_members(self, group_name=None):
"""
Expand Down

0 comments on commit ca1eae6

Please sign in to comment.