Skip to content

Commit 13381fd

Browse files
committed
Make the Issuer on the Response Optional
1 parent ef5c8dd commit 13381fd

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

lib/Saml2/Error.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class OneLogin_Saml2_ValidationError extends Exception
7878
const WRONG_DESTINATION = 24;
7979
const EMPTY_DESTINATION = 25;
8080
const WRONG_AUDIENCE = 26;
81-
const ISSUER_NOT_FOUND_IN_RESPONSE = 27;
81+
const ISSUER_MULTIPLE_IN_RESPONSE = 27;
8282
const ISSUER_NOT_FOUND_IN_ASSERTION = 28;
8383
const WRONG_ISSUER = 29;
8484
const SESSION_EXPIRED = 30;

lib/Saml2/Response.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -523,13 +523,15 @@ public function getIssuers()
523523
$issuers = array();
524524

525525
$responseIssuer = OneLogin_Saml2_Utils::query($this->document, '/samlp:Response/saml:Issuer');
526-
if ($responseIssuer->length == 1) {
527-
$issuers[] = $responseIssuer->item(0)->textContent;
528-
} else {
529-
throw new OneLogin_Saml2_ValidationError(
530-
"Issuer of the Response not found or multiple.",
531-
OneLogin_Saml2_ValidationError::ISSUER_NOT_FOUND_IN_RESPONSE
532-
);
526+
if ($responseIssuer->length > 0) {
527+
if ($responseIssuer->length == 1) {
528+
$issuers[] = $responseIssuer->item(0)->textContent;
529+
} else {
530+
throw new OneLogin_Saml2_ValidationError(
531+
"Issuer of the Response is multiple.",
532+
OneLogin_Saml2_ValidationError::ISSUER_MULTIPLE_IN_RESPONSE
533+
);
534+
}
533535
}
534536

535537
$assertionIssuer = $this->_queryAssertion('/saml:Issuer');

tests/src/OneLogin/Saml2/ResponseTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -490,12 +490,8 @@ public function testGetIssuers()
490490

491491
$xml4 = file_get_contents(TEST_ROOT . '/data/responses/invalids/no_issuer_response.xml.base64');
492492
$response4 = new OneLogin_Saml2_Response($this->_settings, $xml4);
493-
try {
494-
$issuers = $response4->getIssuers();
495-
$this->fail('OneLogin_Saml2_ValidationError was not raised');
496-
} catch (OneLogin_Saml2_ValidationError $e) {
497-
$this->assertContains('Issuer of the Response not found or multiple.', $e->getMessage());
498-
}
493+
$issuers = $response4->getIssuers();
494+
$this->assertEquals(array('http://idp.example.com/'), $response4->getIssuers());
499495

500496
$xml5 = file_get_contents(TEST_ROOT . '/data/responses/invalids/no_issuer_assertion.xml.base64');
501497
$response5 = new OneLogin_Saml2_Response($this->_settings, $xml5);

0 commit comments

Comments
 (0)