Skip to content

Commit efb2945

Browse files
committed
Retrieve SLO endpoint by the appropriate service type
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent e1761c3 commit efb2945

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

src/saml2/entity.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,10 +1115,17 @@ def _parse_response(self, xmlstr, response_cls, service, binding,
11151115
return response
11161116

11171117
if "return_addrs" not in kwargs:
1118-
if binding in [BINDING_HTTP_REDIRECT, BINDING_HTTP_POST]:
1118+
bindings = {
1119+
BINDING_SOAP,
1120+
BINDING_HTTP_REDIRECT,
1121+
BINDING_HTTP_POST,
1122+
}
1123+
if binding in bindings:
11191124
# expected return address
11201125
kwargs["return_addrs"] = self.config.endpoint(
1121-
service, binding=binding)
1126+
service,
1127+
binding=binding,
1128+
context=self.entity_type)
11221129

11231130
try:
11241131
response = response_cls(self.sec, **kwargs)

tests/test_51_client.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,6 +1581,43 @@ def test_negotiated_post_sso(self):
15811581
assert ac.authn_context_class_ref.text == INTERNETPROTOCOLPASSWORD
15821582

15831583

1584+
class TestClientNoConfigContext():
1585+
def setup_class(self):
1586+
self.server = FakeIDP("idp_all_conf")
1587+
1588+
conf = config.Config() # not SPConfig
1589+
conf.load_file("servera_conf")
1590+
self.client = Saml2Client(conf)
1591+
1592+
self.client.send = self.server.receive
1593+
1594+
def test_logout_1(self):
1595+
""" one IdP/AA logout from"""
1596+
1597+
# information about the user from an IdP
1598+
session_info = {
1599+
"name_id": nid,
1600+
"issuer": "urn:mace:example.com:saml:roland:idp",
1601+
"not_on_or_after": in_a_while(minutes=15),
1602+
"ava": {
1603+
"givenName": "Anders",
1604+
"sn": "Andersson",
1605+
1606+
}
1607+
}
1608+
self.client.users.add_information_about_person(session_info)
1609+
entity_ids = self.client.users.issuers_of_info(nid)
1610+
assert entity_ids == ["urn:mace:example.com:saml:roland:idp"]
1611+
resp = self.client.global_logout(nid, "Tired", in_a_while(minutes=5))
1612+
assert resp
1613+
assert len(resp) == 1
1614+
assert list(resp.keys()) == entity_ids
1615+
response = resp[entity_ids[0]]
1616+
assert isinstance(response, LogoutResponse)
1617+
assert response.return_addrs
1618+
assert len(response.return_addrs) == 1
1619+
1620+
15841621
def test_parse_soap_enveloped_saml_xxe():
15851622
xml = """<?xml version="1.0"?>
15861623
<!DOCTYPE lolz [

0 commit comments

Comments
 (0)