Skip to content
Draft

WIP #7628

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/scripts/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ services:
image: "docker.io/pulp/pulp-fixtures:latest"
env:
BASE_URL: "http://pulp-fixtures:8080"
- name: "saml2-idp"
image: "ghcr.io/pfrest/mock-saml2-idp:latest"
env:
SP_ENTITY_ID: "http://pulp"
SP_ACS_LOCATION: "http://pulp/saml/acs/"
VARSYAML

if [ "$TEST" = "s3" ]; then
Expand Down
2 changes: 1 addition & 1 deletion ci_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@

pulpcore[saml2]
17 changes: 16 additions & 1 deletion pulpcore/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,21 @@ def otel_middleware_hook(settings):
return data


def saml2_settings_hook(settings):
data = {"dynaconf_merge": True}
if "LOGIN_URL" not in settings:
data["LOGIN_URL"] = "/saml2/login/"
if "SESSION_COOKIE_SECURE" not in settings:
data["SESSION_COOKIE_SECURE"] = True
if "SESSION_EXPIRE_AT_BROWSER_CLOSE" not in settings:
data["SESSION_EXPIRE_AT_BROWSER_CLOSE"] = True
if "SAML_CONFIG" in settings:
data["INSTALLED_APPS"] = ["djangosaml2"]
data["MIDDLEWARE"] = ["djangosaml2.middleware.SamlSessionMiddleware"]
data["AUTHENTICATION_BACKENDS"] = ["djangosaml2.backends.Saml2Backend"]
return data


del preload_settings

settings = DjangoDynaconf(
Expand All @@ -618,7 +633,7 @@ def otel_middleware_hook(settings):
otel_metrics_dispatch_interval_validator,
distributed_publication_retention_period_validator,
],
post_hooks=(otel_middleware_hook,),
post_hooks=(otel_middleware_hook, saml2_settings_hook),
)

_logger = getLogger(__name__)
Expand Down
3 changes: 3 additions & 0 deletions pulpcore/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ class NoSchema(p.callback.cls):
path("", include("social_django.urls", namespace=settings.SOCIAL_AUTH_URL_NAMESPACE))
)

if "djangosaml2" in settings.INSTALLED_APPS:
urlpatterns.append(path("saml2/", include("djangosaml2.urls")))

#: The Pulp Platform v3 API router, which can be used to manually register ViewSets with the API.
root_router = PulpDefaultRouter()

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ s3 = ["django-storages[boto3]==1.14.6"]
google = ["django-storages[google]==1.14.6"]
azure = ["django-storages[azure]==1.14.6"]
prometheus = ["django-prometheus"]
saml2 = ["djangosaml2>=1.12.0,<1.13"]
kafka = [
# Pinned because project warns "things might (and will) break with every update"
"cloudevents==1.11.0",
Expand Down
Loading