Skip to content

Commit 1719b74

Browse files
committed
WIP
1 parent 9d26e95 commit 1719b74

5 files changed

Lines changed: 26 additions & 2 deletions

File tree

.github/workflows/scripts/before_install.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ services:
7979
image: "docker.io/pulp/pulp-fixtures:latest"
8080
env:
8181
BASE_URL: "http://pulp-fixtures:8080"
82+
- name: "saml2-idp"
83+
image: "ghcr.io/pfrest/mock-saml2-idp:latest"
84+
env:
85+
SP_ENTITY_ID: "http://pulp"
86+
SP_ACS_LOCATION: "http://pulp/saml/acs/"
8287
VARSYAML
8388

8489
if [ "$TEST" = "s3" ]; then

ci_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1+
pulpcore[saml2]

pulpcore/app/settings.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,21 @@ def otel_middleware_hook(settings):
594594
return data
595595

596596

597+
def saml2_settings_hook(settings):
598+
data = {"dynaconf_merge": True}
599+
if "LOGIN_URL" not in settings:
600+
data["LOGIN_URL"] = "/saml2/login/"
601+
if "SESSION_COOKIE_SECURE" not in settings:
602+
data["SESSION_COOKIE_SECURE"] = True
603+
if "SESSION_EXPIRE_AT_BROWSER_CLOSE" not in settings:
604+
data["SESSION_EXPIRE_AT_BROWSER_CLOSE"] = True
605+
if "SAML_CONFIG" in settings:
606+
data["INSTALLED_APPS"] = ["djangosaml2"]
607+
data["MIDDLEWARE"] = ["djangosaml2.middleware.SamlSessionMiddleware"]
608+
data["AUTHENTICATION_BACKENDS"] = ["djangosaml2.backends.Saml2Backend"]
609+
return data
610+
611+
597612
del preload_settings
598613

599614
settings = DjangoDynaconf(
@@ -618,7 +633,7 @@ def otel_middleware_hook(settings):
618633
otel_metrics_dispatch_interval_validator,
619634
distributed_publication_retention_period_validator,
620635
],
621-
post_hooks=(otel_middleware_hook,),
636+
post_hooks=(otel_middleware_hook, saml2_settings_hook),
622637
)
623638

624639
_logger = getLogger(__name__)

pulpcore/app/urls.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ class NoSchema(p.callback.cls):
245245
path("", include("social_django.urls", namespace=settings.SOCIAL_AUTH_URL_NAMESPACE))
246246
)
247247

248+
if "djangosaml2" in settings.INSTALLED_APPS:
249+
urlpatterns.append(path("saml2/", include("djangosaml2.urls")))
250+
248251
#: The Pulp Platform v3 API router, which can be used to manually register ViewSets with the API.
249252
root_router = PulpDefaultRouter()
250253

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ s3 = ["django-storages[boto3]==1.14.6"]
7373
google = ["django-storages[google]==1.14.6"]
7474
azure = ["django-storages[azure]==1.14.6"]
7575
prometheus = ["django-prometheus"]
76+
saml2 = ["djangosaml2>=1.12.0,<1.13"]
7677
kafka = [
7778
# Pinned because project warns "things might (and will) break with every update"
7879
"cloudevents==1.11.0",

0 commit comments

Comments
 (0)