Skip to content

Commit 2c3c426

Browse files
committed
Validate the audience of assertions regardless of a response being unsolicited
Fixes #609 Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent 2f2b02d commit 2c3c426

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/saml2/response.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -611,10 +611,9 @@ def condition_ok(self, lax=False):
611611
else:
612612
self.not_on_or_after = 0
613613

614-
if not self.allow_unsolicited:
615-
if not for_me(conditions, self.entity_id):
616-
if not lax:
617-
raise Exception("Not for me!!!")
614+
if not for_me(conditions, self.entity_id):
615+
if not lax:
616+
raise Exception("Not for me!!!")
618617

619618
if conditions.condition: # extra conditions
620619
for cond in conditions.condition:

tests/test_44_authnresp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def test_unpack_nested_eptid(self):
162162
</saml:Subject>
163163
<saml:Conditions NotBefore="2016-09-23T14:00:44Z">
164164
<saml:AudienceRestriction>
165-
<saml:Audience>https://sp.example.com</saml:Audience>
165+
<saml:Audience>urn:mace:example.com:saml:roland:sp</saml:Audience>
166166
</saml:AudienceRestriction>
167167
</saml:Conditions>
168168
<saml:AuthnStatement AuthnInstant="2016-09-23T13:55:40Z"
@@ -222,7 +222,7 @@ def test_multiple_attribute_statement(self):
222222
</saml:Subject>
223223
<saml:Conditions NotBefore="2016-09-23T14:00:44Z">
224224
<saml:AudienceRestriction>
225-
<saml:Audience>https://sp.example.com</saml:Audience>
225+
<saml:Audience>urn:mace:example.com:saml:roland:sp</saml:Audience>
226226
</saml:AudienceRestriction>
227227
</saml:Conditions>
228228
<saml:AuthnStatement AuthnInstant="2016-09-23T13:55:40Z"

0 commit comments

Comments
 (0)