Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions modules/saml/lib/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ public static function buildLogoutResponse(
* @param \SimpleSAML\Configuration $spMetadata The metadata of the service provider.
* @param \SimpleSAML\Configuration $idpMetadata The metadata of the identity provider.
* @param \SAML2\Response $response The response.
* @param bool $allowEmptySubjectConfirmationData Whether the assertion should require SubjectConfirmationData.
*
* @return array Array with \SAML2\Assertion objects, containing valid assertions from the response.
*
Expand All @@ -592,7 +593,8 @@ public static function buildLogoutResponse(
public static function processResponse(
Configuration $spMetadata,
Configuration $idpMetadata,
Response $response
Response $response,
$allowEmptySubjectConfirmationData = false
): array {
if (!$response->isSuccess()) {
throw self::getResponseError($response);
Expand All @@ -619,7 +621,7 @@ public static function processResponse(

$ret = [];
foreach ($assertion as $a) {
$ret[] = self::processAssertion($spMetadata, $idpMetadata, $response, $a, $responseSigned);
$ret[] = self::processAssertion($spMetadata, $idpMetadata, $response, $a, $responseSigned, $allowEmptySubjectConfirmationData);
}

return $ret;
Expand All @@ -634,20 +636,22 @@ public static function processResponse(
* @param \SAML2\Response $response The response containing the assertion.
* @param \SAML2\Assertion|\SAML2\EncryptedAssertion $assertion The assertion.
* @param bool $responseSigned Whether the response is signed.
* @param bool $allowEmptySubjectConfirmationData Whether the assertion should require SubjectConfirmationData.
*
* @return \SAML2\Assertion The assertion, if it is valid.
*
* @throws \SimpleSAML\Error\Exception if an error occurs while trying to validate the assertion, or if a assertion
* is not signed and it should be, or if we are unable to decrypt the NameID due to a local failure (missing or
* invalid decryption key).
* @throws \Exception if we couldn't decrypt the NameID for unexpected reasons.
* @throws \SimpleSAML\Error\Exception if an error occurs while trying to validate the assertion, or if a assertion
* is not signed and it should be, or if we are unable to decrypt the NameID due to a local failure (missing or
* invalid decryption key).
*/
private static function processAssertion(
Configuration $spMetadata,
Configuration $idpMetadata,
Response $response,
$assertion,
bool $responseSigned
bool $responseSigned,
$allowEmptySubjectConfirmationData = false
): Assertion {
Assert::isInstanceOfAny($assertion, [\SAML2\Assertion::class, \SAML2\EncryptedAssertion::class]);

Expand Down Expand Up @@ -796,8 +800,13 @@ private static function processAssertion(

// if no SubjectConfirmationData then don't do anything.
if ($scd === null) {
$lastError = 'No SubjectConfirmationData provided';
continue;
if ($allowEmptySubjectConfirmationData) {
$found = true;
break;
} else {
$lastError = 'No SubjectConfirmationData provided';
continue;
}
}

$notBefore = $scd->getNotBefore();
Expand Down