🚚(backend) create a dedicated authentication package
Prepare adding advanced authentication features. Create a dedicated authentication Python package within the core app. This code organization will be more extensible.
This commit is contained in:
committed by
Anthony LC
parent
004a4edfe7
commit
5f7e3e620a
0
src/backend/core/authentication/__init__.py
Normal file
0
src/backend/core/authentication/__init__.py
Normal file
@@ -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.core.exceptions import SuspiciousOperation
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
@@ -8,7 +8,7 @@ from mozilla_django_oidc.auth import (
|
|||||||
OIDCAuthenticationBackend as MozillaOIDCAuthenticationBackend,
|
OIDCAuthenticationBackend as MozillaOIDCAuthenticationBackend,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .models import User
|
from core.models import User
|
||||||
|
|
||||||
|
|
||||||
class OIDCAuthenticationBackend(MozillaOIDCAuthenticationBackend):
|
class OIDCAuthenticationBackend(MozillaOIDCAuthenticationBackend):
|
||||||
0
src/backend/core/tests/authentication/__init__.py
Normal file
0
src/backend/core/tests/authentication/__init__.py
Normal file
@@ -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
|
from django.core.exceptions import SuspiciousOperation
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from core import models
|
from core import models
|
||||||
from core.authentication import OIDCAuthenticationBackend
|
from core.authentication.backends import OIDCAuthenticationBackend
|
||||||
from core.factories import UserFactory
|
from core.factories import UserFactory
|
||||||
|
|
||||||
pytestmark = pytest.mark.django_db
|
pytestmark = pytest.mark.django_db
|
||||||
@@ -206,7 +206,7 @@ class Base(Configuration):
|
|||||||
|
|
||||||
AUTHENTICATION_BACKENDS = [
|
AUTHENTICATION_BACKENDS = [
|
||||||
"django.contrib.auth.backends.ModelBackend",
|
"django.contrib.auth.backends.ModelBackend",
|
||||||
"core.authentication.OIDCAuthenticationBackend",
|
"core.authentication.backends.OIDCAuthenticationBackend",
|
||||||
]
|
]
|
||||||
|
|
||||||
# Django applications from the highest priority to the lowest
|
# Django applications from the highest priority to the lowest
|
||||||
|
|||||||
Reference in New Issue
Block a user