django-epfl-entra-id


Namedjango-epfl-entra-id JSON
Version 0.0.5 PyPI version JSON
download
home_pageNone
SummaryCustom Microsoft Entra ID Authentication Backend for Django.
upload_time2025-08-20 05:41:18
maintainerNone
docs_urlNone
authorNone
requires_python>=3.6
licenseMIT
keywords django entraid oidc authentication
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # django-epfl-entra-id

[![Test Status][github-actions-image]][github-actions-url]
[![Coverage Status][codecov-image]][codecov-url]
[![PyPI version][pypi-image]][pypi-url]

Custom [Microsoft Entra ID][entra-id] Authentication Backend for Django.

## Requirements

- Python 3.6 or later
- Django 1.11, 2.2, 3.2, 4.2 or 5.2

## Installation

```bash
pip install django-epfl-entra-id
```

## Documentation

### Settings

Add `mozilla_django_oidc` to `INSTALLED_APPS`:

```python
INSTALLED_APPS = [
  ...
  "django.contrib.auth",
  "mozilla_django_oidc",  # Load after auth
  ...
]
```

Add `django_epfl_entra_id` authentication backend:

```python
AUTHENTICATION_BACKENDS = ("django_epfl_entra_id.auth.EPFLOIDCAB",)
```

Register your application in the [App Portal][app-portal] and add the OIDC
configuration:

```python
TENANT_ID = os.environ["TENANT_ID"]

OIDC_RP_CLIENT_ID = os.environ["OIDC_RP_CLIENT_ID"]
OIDC_RP_CLIENT_SECRET = os.environ["OIDC_RP_CLIENT_SECRET"]

AUTH_DOMAIN = f"https://login.microsoftonline.com/{TENANT_ID}"
OIDC_OP_AUTHORIZATION_ENDPOINT = f"{AUTH_DOMAIN}/oauth2/v2.0/authorize"
OIDC_OP_TOKEN_ENDPOINT = f"{AUTH_DOMAIN}/oauth2/v2.0/token"
OIDC_OP_JWKS_ENDPOINT = f"{AUTH_DOMAIN}/discovery/v2.0/keys"
OIDC_OP_USER_ENDPOINT = "https://graph.microsoft.com/oidc/userinfo"
OIDC_RP_SIGN_ALGO = "RS256"

LOGIN_URL = "/auth/authenticate"
LOGIN_REDIRECT_URL = "/"
LOGOUT_REDIRECT_URL = "/"
```

### Routing

Edit your `urls.py` and add the following:

```python
urlpatterns = [
  ...
  path("", include("django_epfl_entra_id.urls")),
  path("auth/", include("mozilla_django_oidc.urls")),
  ...
]
```

Example template:

```htmldjango
{% if user.is_authenticated %}
  <p>Current user: {{ user.username }}</p>
  <form action="{% url 'oidc_logout' %}" method="post">
    {% csrf_token %}
    <input type="submit" value="logout">
  </form>
{% else %}
  <a href="{% url 'oidc_authentication_init' %}?next={{ request.path }}">
    Login
  </a>
{% endif %}
```

### Optional configuration

```python
AUTH_PROFILE_MODULE = "userprofile.UserProfile"
```

[github-actions-image]: https://github.com/epfl-si/django-epfl-entra-id/actions/workflows/test.yml/badge.svg?branch=main
[github-actions-url]: https://github.com/epfl-si/django-epfl-entra-id/actions/workflows/test.yml

[codecov-image]: https://codecov.io/gh/epfl-si/django-epfl-entra-id/graph/badge.svg
[codecov-url]: https://codecov.io/gh/epfl-si/django-epfl-entra-id

[entra-id]: https://inside.epfl.ch/identite-numerique/en/digital-identity-protection/
[app-portal]: https://app-portal.epfl.ch/

[pypi-image]: https://img.shields.io/pypi/v/django-epfl-entra-id
[pypi-url]: https://pypi.org/project/django-epfl-entra-id/

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "django-epfl-entra-id",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "django, entraid, oidc, authentication",
    "author": null,
    "author_email": "Lindo Duratti <lindo.duratti@epfl.ch>, William Belle <william.belle@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/2d/70/a31332521ba0b67656030ff6d7041919525d903aa1598e1815e7dc8d3ce7/django_epfl_entra_id-0.0.5.tar.gz",
    "platform": null,
    "description": "# django-epfl-entra-id\n\n[![Test Status][github-actions-image]][github-actions-url]\n[![Coverage Status][codecov-image]][codecov-url]\n[![PyPI version][pypi-image]][pypi-url]\n\nCustom [Microsoft Entra ID][entra-id] Authentication Backend for Django.\n\n## Requirements\n\n- Python 3.6 or later\n- Django 1.11, 2.2, 3.2, 4.2 or 5.2\n\n## Installation\n\n```bash\npip install django-epfl-entra-id\n```\n\n## Documentation\n\n### Settings\n\nAdd `mozilla_django_oidc` to `INSTALLED_APPS`:\n\n```python\nINSTALLED_APPS = [\n  ...\n  \"django.contrib.auth\",\n  \"mozilla_django_oidc\",  # Load after auth\n  ...\n]\n```\n\nAdd `django_epfl_entra_id` authentication backend:\n\n```python\nAUTHENTICATION_BACKENDS = (\"django_epfl_entra_id.auth.EPFLOIDCAB\",)\n```\n\nRegister your application in the [App Portal][app-portal] and add the OIDC\nconfiguration:\n\n```python\nTENANT_ID = os.environ[\"TENANT_ID\"]\n\nOIDC_RP_CLIENT_ID = os.environ[\"OIDC_RP_CLIENT_ID\"]\nOIDC_RP_CLIENT_SECRET = os.environ[\"OIDC_RP_CLIENT_SECRET\"]\n\nAUTH_DOMAIN = f\"https://login.microsoftonline.com/{TENANT_ID}\"\nOIDC_OP_AUTHORIZATION_ENDPOINT = f\"{AUTH_DOMAIN}/oauth2/v2.0/authorize\"\nOIDC_OP_TOKEN_ENDPOINT = f\"{AUTH_DOMAIN}/oauth2/v2.0/token\"\nOIDC_OP_JWKS_ENDPOINT = f\"{AUTH_DOMAIN}/discovery/v2.0/keys\"\nOIDC_OP_USER_ENDPOINT = \"https://graph.microsoft.com/oidc/userinfo\"\nOIDC_RP_SIGN_ALGO = \"RS256\"\n\nLOGIN_URL = \"/auth/authenticate\"\nLOGIN_REDIRECT_URL = \"/\"\nLOGOUT_REDIRECT_URL = \"/\"\n```\n\n### Routing\n\nEdit your `urls.py` and add the following:\n\n```python\nurlpatterns = [\n  ...\n  path(\"\", include(\"django_epfl_entra_id.urls\")),\n  path(\"auth/\", include(\"mozilla_django_oidc.urls\")),\n  ...\n]\n```\n\nExample template:\n\n```htmldjango\n{% if user.is_authenticated %}\n  <p>Current user: {{ user.username }}</p>\n  <form action=\"{% url 'oidc_logout' %}\" method=\"post\">\n    {% csrf_token %}\n    <input type=\"submit\" value=\"logout\">\n  </form>\n{% else %}\n  <a href=\"{% url 'oidc_authentication_init' %}?next={{ request.path }}\">\n    Login\n  </a>\n{% endif %}\n```\n\n### Optional configuration\n\n```python\nAUTH_PROFILE_MODULE = \"userprofile.UserProfile\"\n```\n\n[github-actions-image]: https://github.com/epfl-si/django-epfl-entra-id/actions/workflows/test.yml/badge.svg?branch=main\n[github-actions-url]: https://github.com/epfl-si/django-epfl-entra-id/actions/workflows/test.yml\n\n[codecov-image]: https://codecov.io/gh/epfl-si/django-epfl-entra-id/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/epfl-si/django-epfl-entra-id\n\n[entra-id]: https://inside.epfl.ch/identite-numerique/en/digital-identity-protection/\n[app-portal]: https://app-portal.epfl.ch/\n\n[pypi-image]: https://img.shields.io/pypi/v/django-epfl-entra-id\n[pypi-url]: https://pypi.org/project/django-epfl-entra-id/\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Custom Microsoft Entra ID Authentication Backend for Django.",
    "version": "0.0.5",
    "project_urls": {
        "Changelog": "https://github.com/epfl-si/django-epfl-entra-id/blob/main/CHANGELOG.md",
        "Homepage": "https://github.com/epfl-si/django-epfl-entra-id",
        "Source": "https://github.com/epfl-si/django-epfl-entra-id",
        "Tracker": "https://github.com/epfl-si/django-epfl-entra-id/issues"
    },
    "split_keywords": [
        "django",
        " entraid",
        " oidc",
        " authentication"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "06c60bb9a16e6584e881ec046a60528f0e244385fd905b178d00ed30756ac6b5",
                "md5": "40cb0875636f201f625cbbbdbfa503ab",
                "sha256": "787bc02f2c1bfac3d666cc33edd165cb3d701f072fefa54cc1820094c73e65ad"
            },
            "downloads": -1,
            "filename": "django_epfl_entra_id-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "40cb0875636f201f625cbbbdbfa503ab",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 8679,
            "upload_time": "2025-08-20T05:41:17",
            "upload_time_iso_8601": "2025-08-20T05:41:17.120016Z",
            "url": "https://files.pythonhosted.org/packages/06/c6/0bb9a16e6584e881ec046a60528f0e244385fd905b178d00ed30756ac6b5/django_epfl_entra_id-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2d70a31332521ba0b67656030ff6d7041919525d903aa1598e1815e7dc8d3ce7",
                "md5": "f6573519c96033a977831865604a695a",
                "sha256": "a8b89886e74742a0e0f7441c4866a74b3121985e3128422ecfda900ab3860553"
            },
            "downloads": -1,
            "filename": "django_epfl_entra_id-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "f6573519c96033a977831865604a695a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 7611,
            "upload_time": "2025-08-20T05:41:18",
            "upload_time_iso_8601": "2025-08-20T05:41:18.686074Z",
            "url": "https://files.pythonhosted.org/packages/2d/70/a31332521ba0b67656030ff6d7041919525d903aa1598e1815e7dc8d3ce7/django_epfl_entra_id-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-20 05:41:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "epfl-si",
    "github_project": "django-epfl-entra-id",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "django-epfl-entra-id"
}
        
Elapsed time: 1.04826s