Easily add GitHub Authentication to your Django Projects
Project description
Easily integrate GitHub Authentication into your Django projects
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
- 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
]
-
Navigate to
https://github.com/organizations/<YOUR ORGANIZATION>/settings/applications
, then select or create a newOrg OAuth App
. From that, retrieve yourClient ID
andClient Secret
. -
On the same page, add the address
http://localhost:8000/github_sso/callback/
on the "Authorization callback URL" field. -
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"
- 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
- 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")
),
]
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_github_sso-2.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9850ade9bdc9653584968374b03280613b2920568a58ca00549addc87a5db85b |
|
MD5 | cb188aa072388016df165669b7b47f2a |
|
BLAKE2b-256 | 01b6c60124b9f4288784cefecacd73afa7901a71dde4a745a7ae49f3c2873cb1 |