Skip to content

Commit 0edfb57

Browse files
maxbesc00kiemon5ter
authored andcommitted
Fixes #720: honor ResponseLocation in metadata when building logout responses
1 parent ca60cd9 commit 0edfb57

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/saml2/entity.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
from saml2.samlp import Artifact
5454
from saml2.samlp import LogoutRequest
5555
from saml2.samlp import AttributeQuery
56-
from saml2.mdstore import destinations
56+
from saml2.mdstore import destinations, response_destinations
5757
from saml2 import BINDING_HTTP_POST
5858
from saml2 import BINDING_HTTP_REDIRECT
5959
from saml2 import BINDING_SOAP
@@ -250,7 +250,7 @@ def apply_binding(self, binding, msg_str, destination="", relay_state="",
250250
return info
251251

252252
def pick_binding(self, service, bindings=None, descr_type="", request=None,
253-
entity_id=""):
253+
entity_id="", response=False):
254254
if request and not entity_id:
255255
entity_id = request.issuer.text.strip()
256256

@@ -284,7 +284,10 @@ def pick_binding(self, service, bindings=None, descr_type="", request=None,
284284
if srv["index"] == _index:
285285
return binding, srv["location"]
286286
else:
287-
return binding, destinations(srvs)[0]
287+
if response:
288+
return binding, response_destinations(srvs)[0]
289+
else:
290+
return binding, destinations(srvs)[0]
288291
except UnsupportedBinding:
289292
pass
290293

@@ -351,7 +354,8 @@ def response_args(self, message, bindings=None, descr_type=""):
351354

352355
binding, destination = self.pick_binding(rsrv, bindings,
353356
descr_type=descr_type,
354-
request=message)
357+
request=message,
358+
response=True)
355359
info["binding"] = binding
356360
info["destination"] = destination
357361

src/saml2/mdstore.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,15 @@ def metadata_modules():
149149
return _res
150150

151151

152+
def response_destinations(srvs):
153+
_res = []
154+
for s in srvs:
155+
if "response_location" in s:
156+
_res.append(s["response_location"])
157+
else:
158+
_res.append(s["location"])
159+
return _res
160+
152161
def destinations(srvs):
153162
return [s["location"] for s in srvs]
154163

0 commit comments

Comments
 (0)