Skip to content

Commit 7e4d502

Browse files
committed
Make the Issuer on the Response Optional
1 parent a00e794 commit 7e4d502

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/onelogin/saml2/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class OneLogin_Saml2_ValidationError(Exception):
9494
WRONG_DESTINATION = 24
9595
EMPTY_DESTINATION = 25
9696
WRONG_AUDIENCE = 26
97-
ISSUER_NOT_FOUND_IN_RESPONSE = 27
97+
ISSUER_MULTIPLE_IN_RESPONSE = 27
9898
ISSUER_NOT_FOUND_IN_ASSERTION = 28
9999
WRONG_ISSUER = 29
100100
SESSION_EXPIRED = 30

src/onelogin/saml2/response.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,14 @@ def get_issuers(self):
374374
issuers = []
375375

376376
message_issuer_nodes = OneLogin_Saml2_Utils.query(self.document, '/samlp:Response/saml:Issuer')
377-
if len(message_issuer_nodes) == 1:
378-
issuers.append(message_issuer_nodes[0].text)
379-
else:
380-
raise OneLogin_Saml2_ValidationError(
381-
'Issuer of the Response not found or multiple.',
382-
OneLogin_Saml2_ValidationError.ISSUER_NOT_FOUND_IN_RESPONSE
383-
)
377+
if len(message_issuer_nodes) > 0:
378+
if len(message_issuer_nodes) == 1:
379+
issuers.append(message_issuer_nodes[0].text)
380+
else:
381+
raise OneLogin_Saml2_ValidationError(
382+
'Issuer of the Response is multiple.',
383+
OneLogin_Saml2_ValidationError.ISSUER_MULTIPLE_IN_RESPONSE
384+
)
384385

385386
assertion_issuer_nodes = self.__query_assertion('/saml:Issuer')
386387
if len(assertion_issuer_nodes) == 1:

tests/src/OneLogin/saml2_tests/response_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,8 @@ def testGetIssuers(self):
344344

345345
xml_4 = self.file_contents(join(self.data_path, 'responses', 'invalids', 'no_issuer_response.xml.base64'))
346346
response_4 = OneLogin_Saml2_Response(settings, xml_4)
347-
with self.assertRaisesRegexp(OneLogin_Saml2_ValidationError, 'Issuer of the Response not found or multiple.'):
348-
response_4.get_issuers()
347+
response_4.get_issuers()
348+
self.assertEqual(['https://pitbulk.no-ip.org/simplesaml/saml2/idp/metadata.php'], response_4.get_issuers())
349349

350350
xml_5 = self.file_contents(join(self.data_path, 'responses', 'invalids', 'no_issuer_assertion.xml.base64'))
351351
response_5 = OneLogin_Saml2_Response(settings, xml_5)

0 commit comments

Comments
 (0)