Skip to content

Commit 25d942f

Browse files
committed
Check destination against the getSelfURLNoQuery as well on LogoutRequest and LogoutResponse as we do on Response
1 parent bb34489 commit 25d942f

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

src/Saml2/LogoutRequest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,15 @@ public function isValid($retrieveParametersFromServer = false)
393393
// Check destination
394394
if ($dom->documentElement->hasAttribute('Destination')) {
395395
$destination = $dom->documentElement->getAttribute('Destination');
396-
if (!empty($destination) && strpos($destination, $currentURL) === false) {
397-
throw new ValidationError(
398-
"The LogoutRequest was received at $currentURL instead of $destination",
399-
ValidationError::WRONG_DESTINATION
400-
);
396+
if (!empty($destination) && strpos($destination, $currentURL) !== 0) {
397+
$currentURLNoRouted = Utils::getSelfURLNoQuery();
398+
399+
if (strpos($destination, $currentURLNoRouted) !== 0) {
400+
throw new ValidationError(
401+
"The LogoutRequest was received at $currentURL instead of $destination",
402+
ValidationError::WRONG_DESTINATION
403+
);
404+
}
401405
}
402406
}
403407

src/Saml2/LogoutResponse.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,15 @@ public function isValid($requestId = null, $retrieveParametersFromServer = false
188188
// Check destination
189189
if ($this->document->documentElement->hasAttribute('Destination')) {
190190
$destination = $this->document->documentElement->getAttribute('Destination');
191-
if (!empty($destination) && strpos($destination, $currentURL) === false) {
192-
throw new ValidationError(
193-
"The LogoutResponse was received at $currentURL instead of $destination",
194-
ValidationError::WRONG_DESTINATION
195-
);
191+
if (!empty($destination) && strpos($destination, $currentURL) !== 0) {
192+
$currentURLNoRouted = Utils::getSelfURLNoQuery();
193+
194+
if (strpos($destination, $currentURLNoRouted) !== 0) {
195+
throw new ValidationError(
196+
"The LogoutResponse was received at $currentURL instead of $destination",
197+
ValidationError::WRONG_DESTINATION
198+
);
199+
}
196200
}
197201
}
198202

0 commit comments

Comments
 (0)