From 0438eb0b6afaa5acc2ba29b399b9c1243abb0fb3 Mon Sep 17 00:00:00 2001 From: jedi Date: Sun, 7 Jan 2024 17:53:52 +0100 Subject: [PATCH] add custom authentication and know in settings.py --- core/core/settings.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/core/core/settings.py b/core/core/settings.py index 615ecdc..58b6635 100644 --- a/core/core/settings.py +++ b/core/core/settings.py @@ -33,6 +33,11 @@ ALLOWED_HOSTS = [os.getenv('HTTP_HOST', 'localhost')] MAIL_DOMAIN = os.getenv('MAIL_DOMAIN', 'localhost') +CSRF_TRUSTED_ORIGINS = ["https://" + host for host in ALLOWED_HOSTS] + +LEGACY_USER_NAME = os.getenv('LEGACY_API_USER', 'legacy_user') +LEGACY_USER_PASSWORD = os.getenv('LEGACY_API_PASSWORD', 'legacy_password') + SYSTEM3_VERSION = "0.0.0-dev.0" # Application definition @@ -46,18 +51,24 @@ INSTALLED_APPS = [ 'django.contrib.staticfiles', 'django_extensions', 'rest_framework', - 'rest_framework.authtoken', + 'knox', 'drf_yasg', 'channels', + 'authentication', 'files', 'inventory', 'notify_sessions', ] REST_FRAMEWORK = { - 'TEST_REQUEST_DEFAULT_FORMAT': 'json' + 'TEST_REQUEST_DEFAULT_FORMAT': 'json', + 'DEFAULT_AUTHENTICATION_CLASSES': ('knox.auth.TokenAuthentication',), + 'DEFAULT_PERMISSION_CLASSES': ( + 'rest_framework.permissions.IsAuthenticated', 'rest_framework.permissions.DjangoModelPermissions'), } +AUTH_USER_MODEL = 'authentication.ExtendedUser' + SWAGGER_SETTINGS = { 'SECURITY_DEFINITIONS': { 'api_key': {