From 059fb732645c2535e93933b8d2971e93be2e58d1 Mon Sep 17 00:00:00 2001 From: pulpbot Date: Sun, 7 Dec 2025 00:47:34 +0000 Subject: [PATCH] Update cookiecutter --- .ci/settings/settings.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/.ci/settings/settings.py b/.ci/settings/settings.py index 8c5d04f53..ed037be22 100644 --- a/.ci/settings/settings.py +++ b/.ci/settings/settings.py @@ -4,10 +4,7 @@ ANALYTICS = False ALLOWED_CONTENT_CHECKSUMS = ["sha1", "sha256", "sha512"] -pulp_https = os.environ.get("PULP_HTTPS", "false").lower() == "true" -pulp_oauth2 = os.environ.get("PULP_OAUTH2", "false").lower() == "true" - -if pulp_https and not pulp_oauth2: +if os.environ.get("PULP_HTTPS", "false").lower() == "true": AUTHENTICATION_BACKENDS = "@merge django.contrib.auth.backends.RemoteUserBackend" MIDDLEWARE = "@merge django.contrib.auth.middleware.RemoteUserMiddleware" REST_FRAMEWORK__DEFAULT_AUTHENTICATION_CLASSES = ( @@ -15,14 +12,14 @@ ) REMOTE_USER_ENVIRON_NAME = "HTTP_REMOTEUSER" -if pulp_oauth2: - assert pulp_https +if os.environ.get("PULP_OAUTH2", "false").lower() == "true": + assert os.environ.get("PULP_HTTPS", "false").lower() == "true" def PulpCliFakeOauth2Authentication(*args, **kwargs): # We need to lazy load this. # Otherwise views may be instanciated, before this configuration is merged. - from django.contrib.auth import get_user_model + from django.contrib.auth import authenticate from drf_spectacular.extensions import OpenApiAuthenticationExtension from rest_framework.authentication import BaseAuthentication @@ -30,7 +27,7 @@ class _PulpCliFakeOauth2Authentication(BaseAuthentication): def authenticate(self, request): auth_header = request.META.get("HTTP_AUTHORIZATION") if auth_header == "Bearer DEADBEEF": - return get_user_model().objects.get(username="admin"), None + return authenticate(request, remote_user="admin"), None else: return None @@ -57,5 +54,5 @@ def get_security_definition(self, auto_schema): PULP_CLI_FAKE_OAUTH2_AUTHENTICATION = PulpCliFakeOauth2Authentication REST_FRAMEWORK__DEFAULT_AUTHENTICATION_CLASSES = ( - "pulpcore.app.settings.PULP_CLI_FAKE_OAUTH2_AUTHENTICATION", + "@merge pulpcore.app.settings.PULP_CLI_FAKE_OAUTH2_AUTHENTICATION" )