Bläddra i källkod

[libsaml] Add support for an explicit saml response base url

Erick Tryzelaar 10 år sedan
förälder
incheckning
b8ab65d

+ 6 - 0
desktop/libs/libsaml/src/libsaml/conf.py

@@ -57,6 +57,12 @@ XMLSEC_BINARY = Config(
   type=str,
   help=_t("Xmlsec1 binary path. This program should be executable by the user running Hue."))
 
+BASE_URL = Config(
+  key="base_url",
+  default=None,
+  type=str,
+  help=_t("Optional base url the SAML IdP should use for responses."))
+
 ENTITY_ID = Config(
   key="entity_id",
   default="<base_url>/saml2/metadata/",

+ 6 - 4
desktop/libs/libsaml/src/libsaml/saml_settings.py

@@ -31,10 +31,12 @@ __all__ = (
 
 
 def config_settings_loader(request):
-  base_url = "%(protocol)s%(host)s" % {
-    'protocol': 'https://' if request.is_secure() else 'http://',
-    'host':  request.get_host(),
-  }
+  base_url = libsaml.conf.BASE_URL.get()
+  if base_url is None:
+    base_url = "%(protocol)s%(host)s" % {
+      'protocol': 'https://' if request.is_secure() else 'http://',
+      'host':  request.get_host(),
+    }
 
   entity_id = libsaml.conf.ENTITY_ID.get().replace('<base_url>', base_url)