Skip to content

Commit b4daf21

Browse files
committed
Assert that signed messages on the Redirect- and POST-bindings have a destination set
1 parent 1e89ba1 commit b4daf21

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/SAML2/HTTPPost.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ public function receive(): Message
8787

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

90+
/**
91+
* 3.5.5.2 - SAML Bindings
92+
*
93+
* If the message is signed, the Destination XML attribute in the root SAML element of the protocol
94+
* message MUST contain the URL to which the sender has instructed the user agent to deliver the
95+
* message.
96+
*/
97+
if ($msg->isMessageConstructedWithSignature()) {
98+
Assert::notNull($msg->getDestination()); // Validation of the value must be done upstream
99+
}
100+
90101
if (array_key_exists('RelayState', $_POST)) {
91102
$msg->setRelayState($_POST['RelayState']);
92103
}

src/SAML2/HTTPRedirect.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,15 @@ public function receive(): Message
141141
return $message;
142142
}
143143

144+
/**
145+
* 3.4.5.2 - SAML Bindings
146+
*
147+
* If the message is signed, the Destination XML attribute in the root SAML element of the protocol
148+
* message MUST contain the URL to which the sender has instructed the user agent to deliver the
149+
* message.
150+
*/
151+
Assert::notNull($message->getDestination()); // Validation of the value must be done upstream
152+
144153
if (!array_key_exists('SigAlg', $data)) {
145154
throw new \Exception('Missing signature algorithm.');
146155
}

0 commit comments

Comments
 (0)