django: Add OIDC Authorization code PKCE authentication backend
Add a generic Django authentication backend and related login / logout views enabling to authenticate a user using Keycloak and the OpenID Connect authorization code flow with PKCE ("Proof Key for Code Exchange"). The backend can be easily plugged into any django application by: - adding "swh.auth.django.backends.OIDCAuthorizationCodePKCEBackend" to the AUTHENTICATION_BACKENDS django setting - configuring Keycloak by adding SWH_AUTH_SERVER_URL, SWH_AUTH_REALM_NAME and SWH_AUTH_CLIENT_ID in django settings - adding swh.auth.django.views.urlpatterns to the django application URLs - using the dedicated django views: "oidc-login" and "oidc-logout" Related to T3150
Showing
- mypy.ini 7 additions, 2 deletionsmypy.ini
- pytest.ini 1 addition, 0 deletionspytest.ini
- requirements-django.txt 3 additions, 1 deletionrequirements-django.txt
- swh/auth/django/backends.py 112 additions, 0 deletionsswh/auth/django/backends.py
- swh/auth/django/utils.py 69 additions, 9 deletionsswh/auth/django/utils.py
- swh/auth/django/views.py 152 additions, 0 deletionsswh/auth/django/views.py
- swh/auth/keycloak.py 5 additions, 2 deletionsswh/auth/keycloak.py
- swh/auth/pytest_plugin.py 12 additions, 1 deletionswh/auth/pytest_plugin.py
- swh/auth/tests/conftest.py 12 additions, 0 deletionsswh/auth/tests/conftest.py
- swh/auth/tests/django/app/apptest/settings.py 34 additions, 0 deletionsswh/auth/tests/django/app/apptest/settings.py
- swh/auth/tests/django/app/apptest/urls.py 11 additions, 1 deletionswh/auth/tests/django/app/apptest/urls.py
- swh/auth/tests/django/django_asserts.py 21 additions, 0 deletionsswh/auth/tests/django/django_asserts.py
- swh/auth/tests/django/test_backends.py 151 additions, 0 deletionsswh/auth/tests/django/test_backends.py
- swh/auth/tests/django/test_utils.py 6 additions, 3 deletionsswh/auth/tests/django/test_utils.py
- swh/auth/tests/django/test_views.py 282 additions, 0 deletionsswh/auth/tests/django/test_views.py
- swh/auth/tests/test_utils.py 36 additions, 0 deletionsswh/auth/tests/test_utils.py
- swh/auth/utils.py 35 additions, 0 deletionsswh/auth/utils.py
Loading
Please register or sign in to comment