diff --git a/.gitignore b/.gitignore index 650900c1..de45d5c7 100644 --- a/.gitignore +++ b/.gitignore @@ -348,3 +348,4 @@ coverage.xml # Ignore copied-back autogenerated grpc library translator/*pb2*.py* +.idea/ruff.xml diff --git a/config/settings/base.py b/config/settings/base.py index 0001daf1..289f5f59 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -319,6 +319,12 @@ # Extend middleware to add OIDC auth backend AUTHENTICATION_BACKENDS += ["scram.route_manager.authentication_backends.ESnetAuthBackend"] + # https://docs.djangoproject.com/en/dev/ref/settings/#login-url + LOGIN_URL = "oidc_authentication_init" + + # https://docs.djangoproject.com/en/dev/ref/settings/#logout-url + LOGOUT_URL = "oidc_logout" + # Need to point somewhere otherwise /oidc/logout/ redirects to /oidc/logout/None which 404s # https://github.com/mozilla/mozilla-django-oidc/issues/118 LOGIN_REDIRECT_URL = "/" @@ -327,21 +333,14 @@ # https://github.com/mozilla/mozilla-django-oidc/issues/434 LOGOUT_REDIRECT_URL = "/" - # https://docs.djangoproject.com/en/dev/ref/settings/#login-url - LOGIN_URL = "/" - - # https://docs.djangoproject.com/en/dev/ref/settings/#logout-url - LOGOUT_URL = "/" - OIDC_RP_CLIENT_ID = os.environ.get("OIDC_RP_CLIENT_ID") OIDC_RP_CLIENT_SECRET = os.environ.get("OIDC_RP_CLIENT_SECRET") elif AUTH_METHOD == "local": - # Points to 'route_manager:home' # https://docs.djangoproject.com/en/dev/ref/settings/#login-redirect-url - LOGIN_REDIRECT_URL = "local_auth:login" + LOGIN_REDIRECT_URL = "route_manager:home" - LOGOUT_REDIRECT_URL = "local_auth:logout" + LOGOUT_REDIRECT_URL = "route_manager:home" # https://docs.djangoproject.com/en/dev/ref/settings/#login-url LOGIN_URL = "local_auth:login" diff --git a/config/settings/local.py b/config/settings/local.py index c6618ab3..5e4d7802 100644 --- a/config/settings/local.py +++ b/config/settings/local.py @@ -82,12 +82,6 @@ msg = "oidc is not yet implemented" raise NotImplementedError(msg) -# https://docs.djangoproject.com/en/dev/ref/settings/#login-url -LOGIN_URL = "admin:login" -# https://docs.djangoproject.com/en/dev/ref/settings/#logout-url -LOGOUT_URL = "admin:logout" - - SCRAM_HOSTNAME = env( "SCRAM_HOSTNAME", default="scram_hostname_not_set", diff --git a/requirements/base.txt b/requirements/base.txt index b43b582a..a9116374 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -26,6 +26,6 @@ drf-spectacular # https://github.com/tfranzel/drf-spectacular # OIDC # ------------------------------------------------------------------------------ -mozilla_django_oidc==2.0.0 # https://github.com/mozilla/mozilla-django-oidc +mozilla_django_oidc==4.0.1 # https://github.com/mozilla/mozilla-django-oidc websockets~=10.3 diff --git a/scram/route_manager/context_processors.py b/scram/route_manager/context_processors.py index b87dcf70..e08a2fc5 100644 --- a/scram/route_manager/context_processors.py +++ b/scram/route_manager/context_processors.py @@ -14,6 +14,7 @@ def login_logout(request): """ login_url = reverse(settings.LOGIN_URL) logout_url = reverse(settings.LOGOUT_URL) + return {"login": login_url, "logout": logout_url}