Skip to main content

Easily add GitHub Authentication to your Django Projects

Project description

Django GitHub SSO

Easily integrate GitHub Authentication into your Django projects

PyPI Build PyPI - Python Version PyPI - Django Version

Welcome to Django GitHub SSO

This library aims to simplify the process of authenticating users with GitHub in Django Admin pages, inspired by libraries like django-admin-sso


Documentation


Install

$ pip install django-github-sso

Configure

  1. Add the following to your settings.py INSTALLED_APPS:
# settings.py

INSTALLED_APPS = [
    # other django apps
    "django.contrib.messages",  # Need for Auth messages
    "django_github_sso",  # Add django_github_sso
]
  1. Navigate to https://github.com/organizations/<YOUR ORGANIZATION>/settings/applications, then select or create a new Org OAuth App. From that, retrieve your Client ID and Client Secret.

  2. On the same page, add the address http://localhost:8000/github_sso/callback/ on the "Authorization callback URL" field.

  3. Add both credentials in your settings.py:

# settings.py

GITHUB_SSO_CLIENT_ID = "your Client ID here"
GITHUB_SSO_CLIENT_SECRET = "your Client Secret  here"
  1. Let Django GitHub SSO auto create users which have access to your repositories:
# settings.py

GITHUB_SSO_NEEDED_REPOS = ["example/example-repo"]  # user needs to be a member of all repos listed
  1. In urls.py please add the Django-Github-SSO views:
# urls.py

from django.urls import include, path

urlpatterns = [
    # other urlpatterns...
    path(
        "github_sso/", include("django_github_sso.urls", namespace="django_github_sso")
    ),
]
  1. And run migrations:
$ python manage.py migrate

That's it. Start django on port 8000 and open your browser in http://localhost:8000/admin/login and you should see the GitHub SSO button.


License

This project is licensed under the terms of the MIT license.

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_github_sso-2.1.1.tar.gz (17.1 kB view hashes)

Uploaded Source

Built Distribution

django_github_sso-2.1.1-py3-none-any.whl (22.8 kB view hashes)

Uploaded Python 3

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