Skip to content

Commit 5e630bf

Browse files
committed
Update cookiecutter
1 parent 76ede0c commit 5e630bf

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

.ci/settings/settings.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,30 @@
44
ANALYTICS = False
55
ALLOWED_CONTENT_CHECKSUMS = ["sha1", "sha256", "sha512"]
66

7-
pulp_https = os.environ.get("PULP_HTTPS", "false").lower() == "true"
8-
pulp_oauth2 = os.environ.get("PULP_OAUTH2", "false").lower() == "true"
9-
10-
if pulp_https and not pulp_oauth2:
7+
if os.environ.get("PULP_HTTPS", "false").lower() == "true":
118
AUTHENTICATION_BACKENDS = "@merge django.contrib.auth.backends.RemoteUserBackend"
129
MIDDLEWARE = "@merge django.contrib.auth.middleware.RemoteUserMiddleware"
1310
REST_FRAMEWORK__DEFAULT_AUTHENTICATION_CLASSES = (
1411
"@merge pulpcore.app.authentication.PulpRemoteUserAuthentication"
1512
)
1613
REMOTE_USER_ENVIRON_NAME = "HTTP_REMOTEUSER"
1714

18-
if pulp_oauth2:
19-
assert pulp_https
15+
if os.environ.get("PULP_OAUTH2", "false").lower() == "true":
16+
assert os.environ.get("PULP_HTTPS", "false").lower() == "true"
2017

2118
def PulpCliFakeOauth2Authentication(*args, **kwargs):
2219
# We need to lazy load this.
2320
# Otherwise views may be instanciated, before this configuration is merged.
2421

25-
from django.contrib.auth import get_user_model
22+
from django.contrib.auth import authenticate
2623
from drf_spectacular.extensions import OpenApiAuthenticationExtension
2724
from rest_framework.authentication import BaseAuthentication
2825

2926
class _PulpCliFakeOauth2Authentication(BaseAuthentication):
3027
def authenticate(self, request):
3128
auth_header = request.META.get("HTTP_AUTHORIZATION")
3229
if auth_header == "Bearer DEADBEEF":
33-
return get_user_model().objects.get(username="admin"), None
30+
return authenticate(request, remote_user="admin"), None
3431
else:
3532
return None
3633

@@ -57,5 +54,5 @@ def get_security_definition(self, auto_schema):
5754
PULP_CLI_FAKE_OAUTH2_AUTHENTICATION = PulpCliFakeOauth2Authentication
5855

5956
REST_FRAMEWORK__DEFAULT_AUTHENTICATION_CLASSES = (
60-
"pulpcore.app.settings.PULP_CLI_FAKE_OAUTH2_AUTHENTICATION",
57+
"@merge pulpcore.app.settings.PULP_CLI_FAKE_OAUTH2_AUTHENTICATION"
6158
)

0 commit comments

Comments
 (0)