django-github-sso


Namedjango-github-sso JSON
Version 5.0.2 PyPI version JSON
download
home_pagehttps://github.com/megalus/django-github-sso
SummaryEasily add GitHub Authentication to your Django Projects
upload_time2025-09-16 20:30:41
maintainerNone
docs_urlNone
authorChris Maillefaud
requires_python<4.0,>=3.11
licenseMIT
keywords github django sso
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
  <img src="docs/images/django-github-sso.png" alt="Django GitHub SSO"/>
</p>
<p align="center">
<em>Easily integrate GitHub Authentication into your Django projects</em>
</p>

<p align="center">
<a href="https://pypi.org/project/django-github-sso/" target="_blank">
<img alt="PyPI" src="https://img.shields.io/pypi/v/django-github-sso"/></a>
<a href="https://github.com/megalus/django-github-sso/actions" target="_blank">
<img alt="Build" src="https://github.com/megalus/django-github-sso/workflows/tests/badge.svg"/>
</a>
<a href="https://www.python.org" target="_blank">
<img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/django-github-sso"/>
</a>
<a href="https://www.djangoproject.com/" target="_blank">
<img alt="PyPI - Django Version" src="https://img.shields.io/pypi/djversions/django-github-sso"/>
</a>
<a href="https://github.com/megalus/django-github-sso/blob/main/LICENSE" target="_blank">
<img alt="License" src="https://img.shields.io/github/license/megalus/django-github-sso"/>
</a>
</p>

## Welcome to Django GitHub SSO

This library simplifies the process of authenticating users with GitHub in Django projects. It adds a "Login with GitHub" button to your Django admin login page, allowing users to authenticate using their GitHub accounts.

Unlike more complex solutions like django-allauth, Django GitHub SSO focuses on simplicity and ease of use, with minimal configuration required.

### Features

- Simple integration with Django admin
- Automatic user creation based on GitHub credentials
- Customizable authentication filters (by domain, organization, or repository)
- Compatible with various Django admin skins
- Support for multiple SSO providers
- Light and dark mode support

---

### Documentation

Full documentation is available at: [https://megalus.github.io/django-github-sso/](https://megalus.github.io/django-github-sso/)

---

### Requirements

- Python 3.11+
- Django 4.2+
- A GitHub account or organization

### Installation

```shell
$ pip install django-github-sso
```

> **Compatibility**
> - Python 3.11, 3.12, 3.13
> - Django 4.2, 5.0, 5.1, 5.2
>
> Older python/django versions are not supported.

### Quick Configuration

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

```python
# settings.py

INSTALLED_APPS = [
    # other django apps
    "django.contrib.messages",  # Required for Auth messages
    "django_github_sso",  # Add django_github_sso
]
```

2. Navigate to `https://github.com/organizations/<YOUR ORGANIZATION>/settings/applications`, then select or create a new `OAuth App`.

3. On the GitHub OAuth App settings page, add the address `http://localhost:8000/github_sso/callback/` (or your domain) in the "Authorization callback URL" field.

4. Add your GitHub OAuth credentials to your `settings.py`:

```python
# settings.py

GITHUB_SSO_CLIENT_ID = "your Client ID here"
GITHUB_SSO_CLIENT_SECRET = "your Client Secret here"
```

5. Configure user authorization filters (at least one is required):

```python
# settings.py

# Choose one or more of these options:
GITHUB_SSO_ALLOWABLE_DOMAINS = ["example.com"]  # Check against user's primary email
GITHUB_SSO_ALLOWABLE_ORGS = ["example"]  # User must be a member of all orgs listed
GITHUB_SSO_NEEDED_REPOS = ["example/example-repo"]  # User must have access to all repos listed
```

6. Add the Django GitHub SSO URLs to your `urls.py`:

```python
# urls.py

from django.urls import include, path

urlpatterns = [
    # other urlpatterns...
    path(
        "github_sso/", include("django_github_sso.urls", namespace="django_github_sso")
    ),
]
```

7. Run migrations:

```shell
$ python manage.py migrate
```

That's it! Start Django and navigate to `http://localhost:8000/admin/login` to see the GitHub SSO button:

<p align="center">
   <img src="docs/images/django_login_with_github_light.png"/>
</p>

### Environment Variables

For security, it's recommended to use environment variables for your GitHub credentials:

```python
# settings.py
import os

GITHUB_SSO_CLIENT_ID = os.environ.get("GITHUB_SSO_CLIENT_ID")
GITHUB_SSO_CLIENT_SECRET = os.environ.get("GITHUB_SSO_CLIENT_SECRET")
```

## Example project

A minimal Django project using this library is included in this repository under `example_github_app/`.
- Read the step-by-step instructions in example_github_app/README.md
- Use it as a reference to configure your own project settings and URLs

---

## License

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/megalus/django-github-sso",
    "name": "django-github-sso",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.11",
    "maintainer_email": null,
    "keywords": "github, django, sso",
    "author": "Chris Maillefaud",
    "author_email": "chrismaille@users.noreply.github.com",
    "download_url": "https://files.pythonhosted.org/packages/57/e4/9900ea0520a98fbaa6ec98886bd38ff193127a0b940b7b57d27f1a032698/django_github_sso-5.0.2.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n  <img src=\"docs/images/django-github-sso.png\" alt=\"Django GitHub SSO\"/>\n</p>\n<p align=\"center\">\n<em>Easily integrate GitHub Authentication into your Django projects</em>\n</p>\n\n<p align=\"center\">\n<a href=\"https://pypi.org/project/django-github-sso/\" target=\"_blank\">\n<img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/django-github-sso\"/></a>\n<a href=\"https://github.com/megalus/django-github-sso/actions\" target=\"_blank\">\n<img alt=\"Build\" src=\"https://github.com/megalus/django-github-sso/workflows/tests/badge.svg\"/>\n</a>\n<a href=\"https://www.python.org\" target=\"_blank\">\n<img alt=\"PyPI - Python Version\" src=\"https://img.shields.io/pypi/pyversions/django-github-sso\"/>\n</a>\n<a href=\"https://www.djangoproject.com/\" target=\"_blank\">\n<img alt=\"PyPI - Django Version\" src=\"https://img.shields.io/pypi/djversions/django-github-sso\"/>\n</a>\n<a href=\"https://github.com/megalus/django-github-sso/blob/main/LICENSE\" target=\"_blank\">\n<img alt=\"License\" src=\"https://img.shields.io/github/license/megalus/django-github-sso\"/>\n</a>\n</p>\n\n## Welcome to Django GitHub SSO\n\nThis library simplifies the process of authenticating users with GitHub in Django projects. It adds a \"Login with GitHub\" button to your Django admin login page, allowing users to authenticate using their GitHub accounts.\n\nUnlike more complex solutions like django-allauth, Django GitHub SSO focuses on simplicity and ease of use, with minimal configuration required.\n\n### Features\n\n- Simple integration with Django admin\n- Automatic user creation based on GitHub credentials\n- Customizable authentication filters (by domain, organization, or repository)\n- Compatible with various Django admin skins\n- Support for multiple SSO providers\n- Light and dark mode support\n\n---\n\n### Documentation\n\nFull documentation is available at: [https://megalus.github.io/django-github-sso/](https://megalus.github.io/django-github-sso/)\n\n---\n\n### Requirements\n\n- Python 3.11+\n- Django 4.2+\n- A GitHub account or organization\n\n### Installation\n\n```shell\n$ pip install django-github-sso\n```\n\n> **Compatibility**\n> - Python 3.11, 3.12, 3.13\n> - Django 4.2, 5.0, 5.1, 5.2\n>\n> Older python/django versions are not supported.\n\n### Quick Configuration\n\n1. Add the following to your `settings.py` `INSTALLED_APPS`:\n\n```python\n# settings.py\n\nINSTALLED_APPS = [\n    # other django apps\n    \"django.contrib.messages\",  # Required for Auth messages\n    \"django_github_sso\",  # Add django_github_sso\n]\n```\n\n2. Navigate to `https://github.com/organizations/<YOUR ORGANIZATION>/settings/applications`, then select or create a new `OAuth App`.\n\n3. On the GitHub OAuth App settings page, add the address `http://localhost:8000/github_sso/callback/` (or your domain) in the \"Authorization callback URL\" field.\n\n4. Add your GitHub OAuth credentials to your `settings.py`:\n\n```python\n# settings.py\n\nGITHUB_SSO_CLIENT_ID = \"your Client ID here\"\nGITHUB_SSO_CLIENT_SECRET = \"your Client Secret here\"\n```\n\n5. Configure user authorization filters (at least one is required):\n\n```python\n# settings.py\n\n# Choose one or more of these options:\nGITHUB_SSO_ALLOWABLE_DOMAINS = [\"example.com\"]  # Check against user's primary email\nGITHUB_SSO_ALLOWABLE_ORGS = [\"example\"]  # User must be a member of all orgs listed\nGITHUB_SSO_NEEDED_REPOS = [\"example/example-repo\"]  # User must have access to all repos listed\n```\n\n6. Add the Django GitHub SSO URLs to your `urls.py`:\n\n```python\n# urls.py\n\nfrom django.urls import include, path\n\nurlpatterns = [\n    # other urlpatterns...\n    path(\n        \"github_sso/\", include(\"django_github_sso.urls\", namespace=\"django_github_sso\")\n    ),\n]\n```\n\n7. Run migrations:\n\n```shell\n$ python manage.py migrate\n```\n\nThat's it! Start Django and navigate to `http://localhost:8000/admin/login` to see the GitHub SSO button:\n\n<p align=\"center\">\n   <img src=\"docs/images/django_login_with_github_light.png\"/>\n</p>\n\n### Environment Variables\n\nFor security, it's recommended to use environment variables for your GitHub credentials:\n\n```python\n# settings.py\nimport os\n\nGITHUB_SSO_CLIENT_ID = os.environ.get(\"GITHUB_SSO_CLIENT_ID\")\nGITHUB_SSO_CLIENT_SECRET = os.environ.get(\"GITHUB_SSO_CLIENT_SECRET\")\n```\n\n## Example project\n\nA minimal Django project using this library is included in this repository under `example_github_app/`.\n- Read the step-by-step instructions in example_github_app/README.md\n- Use it as a reference to configure your own project settings and URLs\n\n---\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Easily add GitHub Authentication to your Django Projects",
    "version": "5.0.2",
    "project_urls": {
        "Homepage": "https://github.com/megalus/django-github-sso",
        "Repository": "https://github.com/megalus/django-github-sso"
    },
    "split_keywords": [
        "github",
        " django",
        " sso"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "80d9f028d41f36d47d4a8ae2c456213b08811f5044b1a1f2fd2e4f08c44580b5",
                "md5": "c8f08897df19a99e2fd3b19b3a26ee3b",
                "sha256": "a878dd4ccd2a2f602d9d359214fe8f334f181333bb9169b43639fc3b0c0082bf"
            },
            "downloads": -1,
            "filename": "django_github_sso-5.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c8f08897df19a99e2fd3b19b3a26ee3b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 33304,
            "upload_time": "2025-09-16T20:30:40",
            "upload_time_iso_8601": "2025-09-16T20:30:40.119098Z",
            "url": "https://files.pythonhosted.org/packages/80/d9/f028d41f36d47d4a8ae2c456213b08811f5044b1a1f2fd2e4f08c44580b5/django_github_sso-5.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "57e49900ea0520a98fbaa6ec98886bd38ff193127a0b940b7b57d27f1a032698",
                "md5": "c29bcd6e7b0d8254b0fdfaccac844af6",
                "sha256": "e24a4d14fbd2d3b323889c3bba0b53e595c6716125a6b454ccd826946f378e67"
            },
            "downloads": -1,
            "filename": "django_github_sso-5.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "c29bcd6e7b0d8254b0fdfaccac844af6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 24575,
            "upload_time": "2025-09-16T20:30:41",
            "upload_time_iso_8601": "2025-09-16T20:30:41.203481Z",
            "url": "https://files.pythonhosted.org/packages/57/e4/9900ea0520a98fbaa6ec98886bd38ff193127a0b940b7b57d27f1a032698/django_github_sso-5.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-16 20:30:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "megalus",
    "github_project": "django-github-sso",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "django-github-sso"
}
        
Elapsed time: 0.67902s