Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for a mapping file #3

Closed
primetheus opened this issue Nov 12, 2018 · 8 comments · Fixed by #33
Closed

Add support for a mapping file #3

primetheus opened this issue Nov 12, 2018 · 8 comments · Fixed by #33
Assignees
Labels
enhancement New feature or request

Comments

@primetheus
Copy link
Collaborator

At present, this script requires each team and group to be sync'ed separately. This means creating a wrapper to run python SAMLTeamSyncAD.py -g <ad_group> -t <gh_team> -o <gh_org> -s repeatedly to sync multiple teams. You can accomplish this with a wrapper script, but it would be ideal if this script could handle the mapping of multiples at once, fed via YAML

@primetheus primetheus added the enhancement New feature or request label Nov 12, 2018
@primetheus primetheus self-assigned this Nov 12, 2018
@primetheus
Copy link
Collaborator Author

short-term fix for this could be to wrap the script...

#!/usr/bin/env python

script_dir = os.path.dirname(os.path.realpath(__file__))
settings_file = "{}/settings.ini".format(script_dir)
DATAFILE = "mapping.csv"

# Format the mapping file like this 
#<org>,<team>,<ldap-group>

try:
    with open(DATAFILE) as datafile:
        for line in datafile:
            [ org, team, group ] = line.split(",")
	    try:
		syncstr = "--sync --org {} --team {} --group {}".format(org, team, group) 
	        print("Syncing ORG: {}, TEAM: {}, LDAP_GROUP: {}".format(org, team, group)
	        os.system("{}/SAMLTeamSyncAD.py {}".format(script_dir, syncstr))
            except:
	        raise
except:
    raise
    
print "Sync completed!!"

@kumar0608
Copy link

@primetheus
Thanks for the wrapper script, but it is little bit pain to maintain the csv files every time,
In real-time GHE-Team and Ldap groups should be the same name always

If we are using GitHub enterprise service account user(API token) which will have access to all the organizations, so, in this case, get the teams from each org and search that team in LDAP, if we found the GHE-Team in LDAP groups then we have to sync, if not then leave it and continue to the next team, it should be done for all ORGS.

Thanks
Pragnya

@primetheus
Copy link
Collaborator Author

@kumar0608 thanks for this context! So, if I’m understanding this correctly, the functionality you’d like to see is:

  1. Look up teams in GitHub
  2. Iterate over each team
  3. Look up a team in LDAP that matches the name exactly
  4. Sync the LDAP team to GitHub
  5. Skip teams that aren’t found in LDAP

Is that accurate? I think that is pretty feasible and should be simple to implement. Then the additional flags can serve as overrides or additions.

@kumar0608
Copy link

yes exactly.

This was referenced Jun 17, 2020
@primetheus
Copy link
Collaborator Author

@kumar0608 #33 is ready for testing, if you'd like to try it out. The README of that branch has been updated with instructions

@kumar0608
Copy link

kumar0608 commented Jul 2, 2020 via email

@kumar0608
Copy link

kumar0608 commented Jul 2, 2020 via email

@kumar0608
Copy link

kumar0608 commented Jul 3, 2020 via email

primetheus pushed a commit that referenced this issue Apr 12, 2021
primetheus pushed a commit that referenced this issue Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants