{"id":23114364,"url":"https://github.com/snok/django-auth-adfs","last_synced_at":"2026-01-08T09:05:39.255Z","repository":{"id":38009452,"uuid":"51428483","full_name":"snok/django-auth-adfs","owner":"snok","description":"A Django authentication backend for Microsoft ADFS and AzureAD","archived":false,"fork":false,"pushed_at":"2025-05-08T15:35:55.000Z","size":5359,"stargazers_count":283,"open_issues_count":39,"forks_count":105,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-05-13T10:17:51.559Z","etag":null,"topics":["adfs","authentication","azure-active-directory","django","drf","jwt","oauth2","openid-connect","restframework"],"latest_commit_sha":null,"homepage":"http://django-auth-adfs.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/snok.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING.rst","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["jobec","jonasks","sondrelg"]}},"created_at":"2016-02-10T08:15:03.000Z","updated_at":"2025-05-09T12:25:51.000Z","dependencies_parsed_at":"2023-12-18T09:25:20.854Z","dependency_job_id":"ce5ddd52-d9c1-4d06-af38-f4d8e625149f","html_url":"https://github.com/snok/django-auth-adfs","commit_stats":{"total_commits":382,"total_committers":52,"mean_commits":7.346153846153846,"dds":0.7172774869109948,"last_synced_commit":"80adc32b468e2e7b6f28a84d574012910bc13450"},"previous_names":["jobec/django-auth-adfs"],"tags_count":48,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snok%2Fdjango-auth-adfs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snok%2Fdjango-auth-adfs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snok%2Fdjango-auth-adfs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snok%2Fdjango-auth-adfs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snok","download_url":"https://codeload.github.com/snok/django-auth-adfs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254198452,"owners_count":22030964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adfs","authentication","azure-active-directory","django","drf","jwt","oauth2","openid-connect","restframework"],"created_at":"2024-12-17T03:29:45.704Z","updated_at":"2026-01-08T09:05:34.223Z","avatar_url":"https://github.com/snok.png","language":"Python","funding_links":["https://github.com/sponsors/jobec","https://github.com/sponsors/jonasks","https://github.com/sponsors/sondrelg"],"categories":[],"sub_categories":[],"readme":"ADFS Authentication for Django\n==============================\n\n.. image:: https://readthedocs.org/projects/django-auth-adfs/badge/?version=latest\n    :target: http://django-auth-adfs.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation Status\n.. image:: https://img.shields.io/pypi/v/django-auth-adfs.svg\n    :target: https://pypi.python.org/pypi/django-auth-adfs\n.. image:: https://img.shields.io/pypi/pyversions/django-auth-adfs.svg\n    :target: https://pypi.python.org/pypi/django-auth-adfs#downloads\n.. image:: https://img.shields.io/pypi/djversions/django-auth-adfs.svg\n    :target: https://pypi.python.org/pypi/django-auth-adfs\n.. image:: https://codecov.io/github/snok/django-auth-adfs/coverage.svg?branch=main\n    :target: https://codecov.io/github/snok/django-auth-adfs?branch=main\n\nA Django authentication backend for Microsoft ADFS and Azure AD\n\n* Free software: BSD License\n* Homepage: https://github.com/snok/django-auth-adfs\n* Documentation: http://django-auth-adfs.readthedocs.io/\n\nFeatures\n--------\n\n* Integrates Django with Active Directory on Windows 2012 R2, 2016 or Azure AD in the cloud.\n* Provides seamless single sign on (SSO) for your Django project on intranet environments.\n* Auto creates users and adds them to Django groups based on info received from ADFS.\n* Django Rest Framework (DRF) integration: Authenticate against your API with an ADFS access token.\n\nInstallation\n------------\n\nPython package::\n\n    pip install django-auth-adfs\n\nIn your project's ``settings.py`` add these settings.\n\n.. code-block:: python\n\n    AUTHENTICATION_BACKENDS = (\n        ...\n        'django_auth_adfs.backend.AdfsAuthCodeBackend',\n        ...\n    )\n\n    INSTALLED_APPS = (\n        ...\n        # Needed for the ADFS redirect URI to function\n        'django_auth_adfs',\n        ...\n\n    # checkout the documentation for more settings\n    AUTH_ADFS = {\n        \"SERVER\": \"adfs.yourcompany.com\",\n        \"CLIENT_ID\": \"your-configured-client-id\",\n        \"RELYING_PARTY_ID\": \"your-adfs-RPT-name\",\n        # Make sure to read the documentation about the AUDIENCE setting\n        # when you configured the identifier as a URL!\n        \"AUDIENCE\": \"microsoft:identityserver:your-RelyingPartyTrust-identifier\",\n        \"CA_BUNDLE\": \"/path/to/ca-bundle.pem\",\n        \"CLAIM_MAPPING\": {\"first_name\": \"given_name\",\n                          \"last_name\": \"family_name\",\n                          \"email\": \"email\"},\n    }\n\n    # Configure django to redirect users to the right URL for login\n    LOGIN_URL = \"django_auth_adfs:login\"\n    LOGIN_REDIRECT_URL = \"/\"\n\n    ########################\n    # OPTIONAL SETTINGS\n    ########################\n\n    MIDDLEWARE = (\n        ...\n        # With this you can force a user to login without using\n        # the LoginRequiredMixin on every view class\n        #\n        # You can specify URLs for which login is not enforced by\n        # specifying them in the LOGIN_EXEMPT_URLS setting.\n        'django_auth_adfs.middleware.LoginRequiredMiddleware',\n    )\n\nIn your project's ``urls.py`` add these paths:\n\n.. code-block:: python\n\n    urlpatterns = [\n        ...\n        path('oauth2/', include('django_auth_adfs.urls')),\n    ]\n\nThis will add these paths to Django:\n\n* ``/oauth2/login`` where users are redirected to, to initiate the login with ADFS.\n* ``/oauth2/login_no_sso`` where users are redirected to, to initiate the login with ADFS but forcing a login screen.\n* ``/oauth2/callback`` where ADFS redirects back to after login. So make sure you set the redirect URI on ADFS to this.\n* ``/oauth2/logout`` which logs out the user from both Django and ADFS.\n\nBelow is sample Django template code to use these paths depending if\nyou'd like to use GET or POST requests. Logging out was deprecated in\n`Django 4.1 \u003chttps://docs.djangoproject.com/en/5.1/releases/4.1/#features-deprecated-in-4-1\u003e`_.\n\n- Using GET requests:\n\n    .. code-block:: html\n\n        \u003ca href=\"{% url 'django_auth_adfs:logout' %}\"\u003eLogout\u003c/a\u003e\n        \u003ca href=\"{% url 'django_auth_adfs:login' %}\"\u003eLogin\u003c/a\u003e\n        \u003ca href=\"{% url 'django_auth_adfs:login-no-sso' %}\"\u003eLogin (no SSO)\u003c/a\u003e\n\n- Using POST requests:\n\n    .. code-block:: html+django\n\n        \u003cform method=\"post\" action=\"{% url 'django_auth_adfs:logout' %}\"\u003e\n            {% csrf_token %}\n            \u003cbutton type=\"submit\"\u003eLogout\u003c/button\u003e\n        \u003c/form\u003e\n        \u003cform method=\"post\" action=\"{% url 'django_auth_adfs:login' %}\"\u003e\n            {% csrf_token %}\n            \u003cinput type=\"hidden\" name=\"next\" value=\"{{ next }}\"\u003e\n            \u003cbutton type=\"submit\"\u003eLogin\u003c/button\u003e\n        \u003c/form\u003e\n        \u003cform method=\"post\" action=\"{% url 'django_auth_adfs:login-no-sso' %}\"\u003e\n            {% csrf_token %}\n            \u003cinput type=\"hidden\" name=\"next\" value=\"{{ next }}\"\u003e\n            \u003cbutton type=\"submit\"\u003eLogin (no SSO)\u003c/button\u003e\n        \u003c/form\u003e\n\nContributing\n------------\nContributions to the code are more then welcome.\nFor more details have a look at the ``CONTRIBUTING.rst`` file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnok%2Fdjango-auth-adfs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnok%2Fdjango-auth-adfs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnok%2Fdjango-auth-adfs/lists"}