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.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d31b0147f9730609e03f240808b8eaa670054be677a1e14f4fb7e31b02858749 |
|
MD5 | 418daa50e3fdbfbc934f0b88946c8ee0 |
|
BLAKE2b-256 | 36ee849d097871abd6a219d9d5e1d552e6400a48daa1b86d1b566409a5b468fe |