From 5f7e3e620a5d2d5f06f9e637cbd694a40fdf3976 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/impress/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} (96%) diff --git a/src/backend/core/authentication/__init__.py b/src/backend/core/authentication/__init__.py new file mode 100644 index 00000000..e69de29b 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 a317e670..bfa2c107 100644 --- a/src/backend/core/authentication.py +++ b/src/backend/core/authentication/backends.py @@ -1,4 +1,4 @@ -"""Authentication for the Impress core app.""" +"""Authentication Backends for the Impress core app.""" from django.core.exceptions import SuspiciousOperation from django.utils.translation import gettext_lazy as _ @@ -8,7 +8,7 @@ from mozilla_django_oidc.auth import ( OIDCAuthenticationBackend as MozillaOIDCAuthenticationBackend, ) -from .models import User +from core.models import User 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 00000000..e69de29b 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 96% rename from src/backend/core/tests/test_authentication_get_or_create_user.py rename to src/backend/core/tests/authentication/test_backends.py index 83c44612..c18635f2 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 UserFactory pytestmark = pytest.mark.django_db diff --git a/src/backend/impress/settings.py b/src/backend/impress/settings.py index d3b2eb28..19f3966e 100755 --- a/src/backend/impress/settings.py +++ b/src/backend/impress/settings.py @@ -206,7 +206,7 @@ class Base(Configuration): AUTHENTICATION_BACKENDS = [ "django.contrib.auth.backends.ModelBackend", - "core.authentication.OIDCAuthenticationBackend", + "core.authentication.backends.OIDCAuthenticationBackend", ] # Django applications from the highest priority to the lowest