From 05d9a09d63f17b76fce68fc444a436762a83cdcf Mon Sep 17 00:00:00 2001 From: Lebaud Antoine Date: Tue, 9 Apr 2024 23:33:30 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=9A(backend)=20create=20a=20dedicated?= =?UTF-8?q?=20authentication=20package?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prepare adding advanced authentication features. Create a dedicated authentication Python package within the core app. This code organization will be more extensible. --- src/backend/core/authentication/__init__.py | 0 .../core/{authentication.py => authentication/backends.py} | 4 ++-- src/backend/core/tests/authentication/__init__.py | 0 .../test_backends.py} | 4 ++-- src/backend/people/settings.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 src/backend/core/authentication/__init__.py rename src/backend/core/{authentication.py => authentication/backends.py} (97%) create mode 100644 src/backend/core/tests/authentication/__init__.py rename src/backend/core/tests/{test_authentication_get_or_create_user.py => authentication/test_backends.py} (98%) diff --git a/src/backend/core/authentication/__init__.py b/src/backend/core/authentication/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/backend/core/authentication.py b/src/backend/core/authentication/backends.py similarity index 97% rename from src/backend/core/authentication.py rename to src/backend/core/authentication/backends.py index 2a45d9f..a4d52c0 100644 --- a/src/backend/core/authentication.py +++ b/src/backend/core/authentication/backends.py @@ -1,4 +1,4 @@ -"""Authentication for the People core app.""" +"""Authentication Backends for the People core app.""" from django.conf import settings from django.core.exceptions import SuspiciousOperation @@ -10,7 +10,7 @@ from mozilla_django_oidc.auth import ( OIDCAuthenticationBackend as MozillaOIDCAuthenticationBackend, ) -from .models import Identity +from core.models import Identity class OIDCAuthenticationBackend(MozillaOIDCAuthenticationBackend): diff --git a/src/backend/core/tests/authentication/__init__.py b/src/backend/core/tests/authentication/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/backend/core/tests/test_authentication_get_or_create_user.py b/src/backend/core/tests/authentication/test_backends.py similarity index 98% rename from src/backend/core/tests/test_authentication_get_or_create_user.py rename to src/backend/core/tests/authentication/test_backends.py index 6bb4974..c0c5dd5 100644 --- a/src/backend/core/tests/test_authentication_get_or_create_user.py +++ b/src/backend/core/tests/authentication/test_backends.py @@ -1,11 +1,11 @@ -"""Unit tests for the `get_or_create_user` function.""" +"""Unit tests for the Authentication Backends.""" from django.core.exceptions import SuspiciousOperation import pytest from core import models -from core.authentication import OIDCAuthenticationBackend +from core.authentication.backends import OIDCAuthenticationBackend from core.factories import IdentityFactory pytestmark = pytest.mark.django_db diff --git a/src/backend/people/settings.py b/src/backend/people/settings.py index c4175e2..ec0d22b 100755 --- a/src/backend/people/settings.py +++ b/src/backend/people/settings.py @@ -182,7 +182,7 @@ class Base(Configuration): AUTHENTICATION_BACKENDS = [ "django.contrib.auth.backends.ModelBackend", - "core.authentication.OIDCAuthenticationBackend", + "core.authentication.backends.OIDCAuthenticationBackend", ] # Django's applications from the highest priority to the lowest