Skip to content

Commit

Permalink
Assert that signed messages on the Redirect- and POST-bindings have a…
Browse files Browse the repository at this point in the history
… destination set
  • Loading branch information
tvdijen committed May 27, 2023
1 parent 1e89ba1 commit b4daf21
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/SAML2/HTTPPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ public function receive(): Message

$msg = Message::fromXML($document->firstChild);

/**
* 3.5.5.2 - SAML Bindings
*
* If the message is signed, the Destination XML attribute in the root SAML element of the protocol
* message MUST contain the URL to which the sender has instructed the user agent to deliver the
* message.
*/
if ($msg->isMessageConstructedWithSignature()) {
Assert::notNull($msg->getDestination()); // Validation of the value must be done upstream
}

if (array_key_exists('RelayState', $_POST)) {
$msg->setRelayState($_POST['RelayState']);
}
Expand Down
9 changes: 9 additions & 0 deletions src/SAML2/HTTPRedirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ public function receive(): Message
return $message;
}

/**
* 3.4.5.2 - SAML Bindings
*
* If the message is signed, the Destination XML attribute in the root SAML element of the protocol
* message MUST contain the URL to which the sender has instructed the user agent to deliver the
* message.
*/
Assert::notNull($message->getDestination()); // Validation of the value must be done upstream

if (!array_key_exists('SigAlg', $data)) {
throw new \Exception('Missing signature algorithm.');
}
Expand Down

0 comments on commit b4daf21

Please sign in to comment.