From 287937457e71d9ff2fdb0131000501f9e821464b Mon Sep 17 00:00:00 2001 From: Andrzej Pragacz Date: Mon, 29 Nov 2021 01:55:08 +0100 Subject: [PATCH] Rename DEFAULT_LOGIN_AUTHENTICATION_BACKEND to LOGIN_DEFAULT_SESSION_AUTHENTICATION_BACKEND --- rest_registration/settings_fields.py | 4 ++-- rest_registration/utils/auth_backends.py | 5 +++-- tests/test_checks.py | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/rest_registration/settings_fields.py b/rest_registration/settings_fields.py index 4a59526..e1e7827 100644 --- a/rest_registration/settings_fields.py +++ b/rest_registration/settings_fields.py @@ -202,13 +202,13 @@ def __new__( """) ), Field( - 'DEFAULT_LOGIN_AUTHENTICATION_BACKEND', + 'LOGIN_DEFAULT_SESSION_AUTHENTICATION_BACKEND', default='django.contrib.auth.backends.ModelBackend', help=dedent("""\ This setting allows to override the backend used in the login function. It may be useful if Django ``AUTHENTICATION_BACKENDS`` setting - does not contain ``django.contrib.auth.backends.ModelBackend``. + does contain multiple values. The value must be a dotted import path string. """), diff --git a/rest_registration/utils/auth_backends.py b/rest_registration/utils/auth_backends.py index 8bfa2fb..6ebb368 100644 --- a/rest_registration/utils/auth_backends.py +++ b/rest_registration/utils/auth_backends.py @@ -6,12 +6,13 @@ def get_login_authentication_backend() -> str: backends = settings.AUTHENTICATION_BACKENDS - default_login_backend = registration_settings.DEFAULT_LOGIN_AUTHENTICATION_BACKEND + default_login_backend = registration_settings.LOGIN_DEFAULT_SESSION_AUTHENTICATION_BACKEND # noqa: E501 if not backends: raise ImproperlyConfigured("No AUTHENTICATION_BACKENDS specified") if len(backends) == 1: return backends[0] if default_login_backend not in backends: raise ImproperlyConfigured( - "DEFAULT_LOGIN_AUTHENTICATION_BACKEND is not in AUTHENTICATION_BACKENDS") + "LOGIN_DEFAULT_SESSION_AUTHENTICATION_BACKEND" + " is not in AUTHENTICATION_BACKENDS") return default_login_backend diff --git a/tests/test_checks.py b/tests/test_checks.py index 417f3b5..bb06f0b 100644 --- a/tests/test_checks.py +++ b/tests/test_checks.py @@ -361,7 +361,7 @@ def test_when_multiple_auth_backends_then_check_succeeds(): @override_rest_registration_settings({ - 'DEFAULT_LOGIN_AUTHENTICATION_BACKEND': 'nonexistent.backend', + 'LOGIN_DEFAULT_SESSION_AUTHENTICATION_BACKEND': 'nonexistent.backend', }) @override_settings( AUTHENTICATION_BACKENDS=[ @@ -376,7 +376,8 @@ def test_when_login_auth_backend_not_in_multiple_auth_backends_then_check_fails( ]) expected_messages = { "invalid authentication backends configuration:" - " DEFAULT_LOGIN_AUTHENTICATION_BACKEND is not in AUTHENTICATION_BACKENDS", + " LOGIN_DEFAULT_SESSION_AUTHENTICATION_BACKEND" + " is not in AUTHENTICATION_BACKENDS", } assert {e.msg for e in errors} == expected_messages