summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Besson <maxime.besson@worteks.com>2020-09-28 18:14:28 +0200
committerIvan Kanakarakis <ivan.kanak@gmail.com>2020-10-27 22:07:54 +0200
commit0edfb57b8863d39a776b9a1c0e288c8f95d845bb (patch)
tree48329014ffaf7fec1e952f7057d8a88889f929dd
parentca60cd969a263570c6fe0b1247e319dcba63f813 (diff)
downloadpysaml2-0edfb57b8863d39a776b9a1c0e288c8f95d845bb.tar.gz
Fixes #720: honor ResponseLocation in metadata when building logout responses
-rw-r--r--src/saml2/entity.py12
-rw-r--r--src/saml2/mdstore.py9
2 files changed, 17 insertions, 4 deletions
diff --git a/src/saml2/entity.py b/src/saml2/entity.py
index 9f564ffa..fad9326a 100644
--- a/src/saml2/entity.py
+++ b/src/saml2/entity.py
@@ -53,7 +53,7 @@ from saml2.samlp import ArtifactResponse
from saml2.samlp import Artifact
from saml2.samlp import LogoutRequest
from saml2.samlp import AttributeQuery
-from saml2.mdstore import destinations
+from saml2.mdstore import destinations, response_destinations
from saml2 import BINDING_HTTP_POST
from saml2 import BINDING_HTTP_REDIRECT
from saml2 import BINDING_SOAP
@@ -250,7 +250,7 @@ class Entity(HTTPBase):
return info
def pick_binding(self, service, bindings=None, descr_type="", request=None,
- entity_id=""):
+ entity_id="", response=False):
if request and not entity_id:
entity_id = request.issuer.text.strip()
@@ -284,7 +284,10 @@ class Entity(HTTPBase):
if srv["index"] == _index:
return binding, srv["location"]
else:
- return binding, destinations(srvs)[0]
+ if response:
+ return binding, response_destinations(srvs)[0]
+ else:
+ return binding, destinations(srvs)[0]
except UnsupportedBinding:
pass
@@ -351,7 +354,8 @@ class Entity(HTTPBase):
binding, destination = self.pick_binding(rsrv, bindings,
descr_type=descr_type,
- request=message)
+ request=message,
+ response=True)
info["binding"] = binding
info["destination"] = destination
diff --git a/src/saml2/mdstore.py b/src/saml2/mdstore.py
index 24fccb4d..41e521ec 100644
--- a/src/saml2/mdstore.py
+++ b/src/saml2/mdstore.py
@@ -149,6 +149,15 @@ def metadata_modules():
return _res
+def response_destinations(srvs):
+ _res = []
+ for s in srvs:
+ if "response_location" in s:
+ _res.append(s["response_location"])
+ else:
+ _res.append(s["location"])
+ return _res
+
def destinations(srvs):
return [s["location"] for s in srvs]