Skip to content

Commit

Permalink
Add assertion to ensure binding matches idpdisco-specs
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Oct 18, 2023
1 parent 8e5fb9b commit 9287aa0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/SAML2/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class Constants extends \SimpleSAML\XMLSecurity\Constants
*/
public const BINDING_HTTP_REDIRECT_DEFLATE = 'urn:oasis:names:tc:SAML:2.0:bindings:URL-Encoding:DEFLATE';

/*
* The URN for the IdP Discovery Protocol binding
*/
public const BINDING_IDPDISC = 'urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol';

/**
* The URN for the PAOS binding.
*/
Expand Down
4 changes: 3 additions & 1 deletion src/SAML2/XML/idpdisc/DiscoveryResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
use SimpleSAML\SAML2\XML\md\AbstractIndexedEndpointType;

/**
Expand Down Expand Up @@ -48,10 +49,11 @@ public function __construct(
array $attributes = [],
array $children = [],
) {
Assert::same($binding, C::BINDING_IDPDISC, ProtocolViolationException::class);
Assert::null(
$unused,
'The \'ResponseLocation\' attribute must be omitted for idpdisc:DiscoveryResponse.',
);
parent::__construct($index, $binding, $location, $isDefault, null, $attributes, $children);
parent::__construct($index, C::BINDING_IDPDISC, $location, $isDefault, null, $attributes, $children);
}
}

0 comments on commit 9287aa0

Please sign in to comment.