From a062c81c5ae1756a7df3bc9bf897acbb2b231bba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Arag=C3=B3n?= Date: Wed, 3 Dec 2025 12:04:46 +0100 Subject: [PATCH] refactor: remove auth plugins --- gateway/main/settings.py | 28 ++----------------- gateway/requirements.txt | 3 -- gateway/tests/api/management/test_commands.py | 1 - 3 files changed, 3 insertions(+), 29 deletions(-) diff --git a/gateway/main/settings.py b/gateway/main/settings.py index 87014179f..dd0db7145 100644 --- a/gateway/main/settings.py +++ b/gateway/main/settings.py @@ -13,7 +13,6 @@ import os import os.path import sys -from datetime import timedelta from pathlib import Path from utils import sanitize_file_path @@ -71,9 +70,6 @@ "django_prometheus", "rest_framework", "rest_framework.authtoken", - "rest_framework_simplejwt", - "allauth", - "allauth.socialaccount", "api", "psycopg2", "drf_yasg", @@ -200,8 +196,7 @@ ] AUTHENTICATION_BACKENDS = [ - # `allauth` specific authentication methods, such as login by e-mail - "allauth.account.auth_backends.AuthenticationBackend", + "django.contrib.auth.backends.ModelBackend", ] # Internationalization @@ -233,13 +228,8 @@ # ============= # AUTH SETTINGS # ============= -SETTINGS_AUTH_MECHANISM = os.environ.get("SETTINGS_AUTH_MECHANISM", "default") -SETTINGS_DEFAULT_AUTH_CLASSES = [ - "rest_framework_simplejwt.authentication.JWTAuthentication", - "dj_rest_auth.jwt_auth.JWTCookieAuthentication", -] +SETTINGS_AUTH_MECHANISM = os.environ.get("SETTINGS_AUTH_MECHANISM", "custom_token") ALL_AUTH_CLASSES_CONFIGURATION = { - "default": SETTINGS_DEFAULT_AUTH_CLASSES, "custom_token": [ "api.authentication.CustomTokenBackend", ], @@ -248,7 +238,7 @@ ], } DJR_DEFAULT_AUTHENTICATION_CLASSES = ALL_AUTH_CLASSES_CONFIGURATION.get( - SETTINGS_AUTH_MECHANISM, SETTINGS_DEFAULT_AUTH_CLASSES + SETTINGS_AUTH_MECHANISM, ["api.authentication.CustomTokenBackend"] ) # mock token value SETTINGS_AUTH_MOCK_TOKEN = os.environ.get("SETTINGS_AUTH_MOCK_TOKEN", "awesome_token") @@ -268,12 +258,6 @@ "PAGE_SIZE": 100, } -REST_AUTH = { - "USE_JWT": True, - # 'JWT_AUTH_COOKIE': 'gateway-app-auth', - # 'JWT_AUTH_REFRESH_COOKIE': 'gateway-refresh-token', -} - SWAGGER_SETTINGS = { "SECURITY_DEFINITIONS": { "Bearer Token": { @@ -288,12 +272,6 @@ SITE_ID = 1 SITE_HOST = os.environ.get("SITE_HOST", "http://localhost:8000") -# Provider specific settings -SIMPLE_JWT = { - "ACCESS_TOKEN_LIFETIME": timedelta(days=10), - "REFRESH_TOKEN_LIFETIME": timedelta(days=20), -} - # custom token auth QUANTUM_PLATFORM_API_BASE_URL = os.environ.get("QUANTUM_PLATFORM_API_BASE_URL", None) # verification fields to check when returned from auth api diff --git a/gateway/requirements.txt b/gateway/requirements.txt index ad78c81a3..b15a57625 100644 --- a/gateway/requirements.txt +++ b/gateway/requirements.txt @@ -1,10 +1,7 @@ cryptography>=44.0.3, <45 djangorestframework>=3.15.2, <4 -django-allauth[socialaccount]>=65.7.0, <66 django-allow-cidr>=0.7.1, <1 -dj-rest-auth>=7.0.0, <8 django-csp>=3.8, <4 -djangorestframework-simplejwt>=5.3.1, <6 django_prometheus>=2.3.1, <3 ray[default]>=2.30.0, <3 Django>=5.2.1, <6 diff --git a/gateway/tests/api/management/test_commands.py b/gateway/tests/api/management/test_commands.py index 37440106f..8545ffbb5 100644 --- a/gateway/tests/api/management/test_commands.py +++ b/gateway/tests/api/management/test_commands.py @@ -1,7 +1,6 @@ """Tests for commands.""" from datetime import datetime -from allauth.socialaccount.models import SocialApp from django.core.management import call_command from ray.dashboard.modules.job.common import JobStatus from rest_framework.test import APITestCase