Skip to main content

django-sync-github-teams is ...

Project description

django-sync-github-teams

django-sync-github-teams adds the ability to sync between Github teams and groups in a Django application. It assumes and requires having users logging in to the Django application using their GitHub accounts via django-allauth. Check the django-allauth documentation for details on how to set it up.

Installing and configuring

Install the package

pip install django-sync-github-teams

The in Django settings:

INSTALLED_APPS = [
   ...
   "django_sync_github_teams",
   "allauth",
   "allauth.account",
   "allauth.socialaccount",
   ...
]

AUTH_SOCIALACCOUNT = {
    ...
    "github": {
        "SCOPE": ["user"]
    },
    ...
}

SYNC_GITHUB_TEAMS = ["myorg/myteam"]
SYNC_GITHUB_TEAMS_TOKEN = "*********************"
SYNC_GITHUB_TEAMS_ON_LOGIN = False

The follwing settings can be used:

  • SYNC_GITHUB_TEAMS: list of strings containing the GitHub teams in the format ORGANIZATION/TEAM to be synced from GitHub. Each team listed will be synced to a local Django group with same name. Only users who have logged in locally using their GitHub accounts get added to the group.
    • SYNC_GITHUB_TEAMS can also be a string with teams in the format ORGANIZATION/TEAM separated by commas with optional surounding whitespace, e.g. SYNC_GITHUB_TEAMS = "myorg/team1, myorg/team2", or just by whitespace, e.g. SYNC_GITHUB_TEAMS = "myorg/team1 myorg/team2".
  • SYNC_GITHUB_TEAMS_TOKEN: string containing a GitHub API Personal access token to be used to read the team members. This token must have permissions to read the members of all of the teams listed in SYNC_GITHUB_TEAMS. See the GitHub API documentation for more details about this.
  • SYNC_GITHUB_TEAMS_ON_LOGIN: boolean; if set to True, a user's group will be populated when they login.

Usage

There's a management command to trigger the sync, which can be used in cronjobs and the like:

./manage.py sync-github-teams

You can also trigger this in some other way from your application somehow:

from django_sync_github_teams.sync import sync_github_teams

sync_github_teams()

This needs to run as often as your application requires. Note that even if you enable syncing teams on login, you still need to sync them offline like this from time to time, because users might leave the teams there where members of when they first logged in.

Contributing

Send merge requests at https://gitlab.com/Linaro/django-sync-github-teams. Follow the existing coding conventions in the code (PEP-8, black), and make sure the all the tests pass and that any new code is covered by tests. Just running make will run all relevant tests.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-sync-github-teams-0.2.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

django_sync_github_teams-0.2.0-py2.py3-none-any.whl (5.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-sync-github-teams-0.2.0.tar.gz.

File metadata

File hashes

Hashes for django-sync-github-teams-0.2.0.tar.gz
Algorithm Hash digest
SHA256 95cd44837095685168e1c9993014624e2c68371d0828d110964d17f170f61d81
MD5 3fd6fdfa145b21956ee0759f10a02f93
BLAKE2b-256 674a18938159187e3784b811edd283b755d124e69c057b1a67bf816cd357dda7

See more details on using hashes here.

File details

Details for the file django_sync_github_teams-0.2.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_sync_github_teams-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a7809e56a410de34927503e1235fead4022096279afc03ee95eac37711df39a2
MD5 389f46097f9e9554fcd4eee3c6ff86e3
BLAKE2b-256 4e065b5fadbddacecc5debfe23e0f10404f4cf4f72f7cbaaacc527bb8f2ef924

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page