Skip to content

Commit f98cb77

Browse files
committed
WIP
1 parent d540bd8 commit f98cb77

5 files changed

Lines changed: 52 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: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,38 @@
439439
# Replaces every non PulpException error msg with "An internal error occured"
440440
REDACT_UNSAFE_EXCEPTIONS = False
441441

442+
# ---------- 8< ---------- 8< ---------
443+
# SAML2 config..
444+
LOGIN_URL = "/saml2/login/"
445+
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
446+
SAML_CONFIG = {
447+
"entityid": "http://localhost:5001/saml2/metadata/",
448+
"entity_category": [],
449+
"service": {
450+
"sp": {
451+
"name": "Pulp CI",
452+
"endpoints": {},
453+
"idp": {
454+
"https://localhost:8443/sso/saml2/idp/metadata.php": {},
455+
},
456+
}
457+
},
458+
"key_file": "/etc/pki/saml2/saml2-private.key",
459+
"cert_file": "/etc/pki/saml2/saml2-public.crt",
460+
"xmlsec_binary": "/usr/bin/xmlsec1",
461+
"metadata": {
462+
# "local": [str(BASE_DIR / "remote_metadata.xml")],
463+
"remote": [
464+
{
465+
"url": "https://saml2idp:8443/sso/saml2/idp/metadata.php",
466+
},
467+
],
468+
},
469+
"debug": 1,
470+
# DANGER!
471+
"disable_ssl_certificate_validation": True,
472+
}
473+
442474
# HERE STARTS DYNACONF EXTENSION LOAD (Keep at the very bottom of settings.py)
443475
# Read more at https://www.dynaconf.com/django/
444476

@@ -594,6 +626,15 @@ def otel_middleware_hook(settings):
594626
return data
595627

596628

629+
def saml2_settings_hook(settings):
630+
data = {"dynaconf_merge": True}
631+
if "SAML_CONFIG" in settings:
632+
data["INSTALLED_APPS"] = ["djangosaml2"]
633+
data["MIDDLEWARE"] = ["djangosaml2.middleware.SamlSessionMiddleware"]
634+
data["AUTHENTICATION_BACKENDS"] = ["djangosaml2.backends.Saml2Backend"]
635+
return data
636+
637+
597638
del preload_settings
598639

599640
settings = DjangoDynaconf(
@@ -618,7 +659,7 @@ def otel_middleware_hook(settings):
618659
otel_metrics_dispatch_interval_validator,
619660
distributed_publication_retention_period_validator,
620661
],
621-
post_hooks=(otel_middleware_hook,),
662+
post_hooks=(otel_middleware_hook, saml2_settings_hook),
622663
)
623664

624665
_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)