diff --git a/src/onelogin/saml2/response.py b/src/onelogin/saml2/response.py index d69242d3..d1b74620 100644 --- a/src/onelogin/saml2/response.py +++ b/src/onelogin/saml2/response.py @@ -792,8 +792,10 @@ def __query_assertion(self, xpath_expr): # Check if the message is signed signed_message_query = '/samlp:Response' + signature_expr message_reference_nodes = self.__query(signed_message_query) - if message_reference_nodes: - message_id = message_reference_nodes[0].get('URI') + # we can have reference node but URI can be empty + message_id = message_reference_nodes and \ + message_reference_nodes[0].get('URI') + if message_id: final_query = "/samlp:Response[@ID=$tagid]/" tagid = message_id[1:] else: @@ -801,8 +803,11 @@ def __query_assertion(self, xpath_expr): final_query += assertion_expr else: assertion_id = assertion_reference_nodes[0].get('URI') - final_query = '/samlp:Response' + assertion_expr + "[@ID=$tagid]" - tagid = assertion_id[1:] + if assertion_id: + final_query = '/samlp:Response' + assertion_expr + "[@ID=$tagid]" + tagid = assertion_id[1:] + else: + final_query = '/samlp:Response' + assertion_expr final_query += xpath_expr return self.__query(final_query, tagid) diff --git a/tests/data/responses/response_with_empty_assertion_reference_uri.xml.base64 b/tests/data/responses/response_with_empty_assertion_reference_uri.xml.base64 new file mode 100644 index 00000000..1b5171bf --- /dev/null +++ b/tests/data/responses/response_with_empty_assertion_reference_uri.xml.base64 @@ -0,0 +1,69 @@ +DQo8c2FtbHA6UmVzcG9uc2UgeG1sbnM6c2FtbD0idXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4w +OmFzc2VydGlvbiIgeG1sbnM6c2FtbHA9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDpwcm90 +b2NvbCIgSUQ9IkdPU0FNTFIxMjkwMTE3NDU3MTc5NCIgVmVyc2lvbj0iMi4wIiBJc3N1ZUluc3Rh +bnQ9IjIwMTAtMTEtMThUMjE6NTc6MzdaIiBEZXN0aW5hdGlvbj0ie3JlY2lwaWVudH0iPg0KICA8 +c2FtbHA6U3RhdHVzPg0KICAgIDxzYW1scDpTdGF0dXNDb2RlIFZhbH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HM9Imh0dHA6 +Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hIiB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3Jn +LzIwMDEvWE1MU2NoZW1hLWluc3RhbmNlIiB4c2k6dHlwZT0ieHM6c3RyaW5nIj5kZW1vPC9zYW1s +OkF0dHJpYnV0ZVZhbHVlPg0KICAgICAgPC9zYW1sOkF0dHJpYnV0ZT4NCiAgICAgIDxzYW1sOkF0 +dHJpYnV0ZSBOYW1lPSJhbm90aGVyX3ZhbHVlIj4NCiAgICAgICAgPHNhbWw6QXR0cmlidXRlVmFs +dWUgeG1sbnM6eHM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hIiB4bWxuczp4c2k9 +Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hLWluc3RhbmNlIiB4c2k6dHlwZT0ieHM6 +c3RyaW5nIj52YWx1ZTwvc2FtbDpBdHRyaWJ1dGVWYWx1ZT4NCiAgICAgIDwvc2FtbDpBdHRyaWJ1 +dGU+DQogICAgPC9zYW1sOkF0dHJpYnV0ZVN0YXRlbWVudD4NCiAgPC9zYW1sOkFzc2VydGlvbj4N +Cjwvc2FtbHA6UmVzcG9uc2U+DQo= diff --git a/tests/data/responses/valid_response_with_unsigned_assertion.xml.base64 b/tests/data/responses/valid_response_with_unsigned_assertion.xml.base64 new file mode 100644 index 00000000..720c5fe4 --- /dev/null +++ b/tests/data/responses/valid_response_with_unsigned_assertion.xml.base64 @@ -0,0 +1 @@ +PD94bWwgdmVyc2lvbj0iMS4wIj8+CjxzYW1scDpSZXNwb25zZSB4bWxuczpzYW1scD0idXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOnByb3RvY29sIiB4bWxuczpzYW1sPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6YXNzZXJ0aW9uIiBJRD0icGZ4MDVmM2NlMTAtMTYxNS1mM2VhLWE5ODgtNjBlMzgwYj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uc2U+Cg== diff --git a/tests/src/OneLogin/saml2_tests/response_test.py b/tests/src/OneLogin/saml2_tests/response_test.py index a51f8e60..63084e86 100644 --- a/tests/src/OneLogin/saml2_tests/response_test.py +++ b/tests/src/OneLogin/saml2_tests/response_test.py @@ -633,6 +633,22 @@ def testQueryAssertions(self): response_7 = OneLogin_Saml2_Response(settings, xml_7) self.assertEqual(['http://idp.example.com/'], response_7.get_issuers()) + def testQueryAssertionsWithEmptyRefenceURI(self): + """ + Tests the __query_assertion if //Signature/Reference/@URI is empty. + """ + settings = OneLogin_Saml2_Settings(self.loadSettingsJSON()) + + # test signed message without reference URI + xml = self.file_contents(join(self.data_path, 'responses', 'response_without_reference_uri.xml.base64')) + response = OneLogin_Saml2_Response(settings, xml) + self.assertEqual('saml@user.com', response.get_nameid()) + + # test signed assertion without reference URI + xml = self.file_contents(join(self.data_path, 'responses', 'response_with_empty_assertion_reference_uri.xml.base64')) + response = OneLogin_Saml2_Response(settings, xml) + self.assertEqual('support@onelogin.com', response.get_nameid()) + def testGetIssuers(self): """ Tests the get_issuers method of the OneLogin_Saml2_Response