Skip to content

Commit

Permalink
set destination of response
Browse files Browse the repository at this point in the history
  • Loading branch information
szabogyula committed Mar 22, 2019
1 parent 1a8ebfb commit 4fb4dbb
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lib/AA/SAML2.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

/**
*
* @author Gyula Szabó <[email protected]>
* @author Gyula Szabó <[email protected]>
* @author Gyula Szabó <[email protected]>
*/
class sspmod_aa_AA_SAML2
{
Expand All @@ -22,8 +19,9 @@ class sspmod_aa_AA_SAML2
private $attributeNameFormat;
private $signAssertion;
private $signResponse;
private $endpointUrl;

public function __construct(\SimpleSAML\Metadata\MetaDataStorageHandler $metadata)
public function __construct($metadata)
{
$this->config = SimpleSAML\Configuration::getConfig('module_aa.php');

Expand Down Expand Up @@ -69,7 +67,7 @@ private function getQuery()
return $query;
}

private function getEntities(\SimpleSAML\Metadata\MetaDataStorageHandler $metadata)
private function getEntities($metadata)
{
/* Getting the related entities metadata objects */
$aaEntityId = $metadata->getMetaDataCurrentEntityID('attributeauthority-hosted');
Expand All @@ -79,12 +77,23 @@ private function getEntities(\SimpleSAML\Metadata\MetaDataStorageHandler $metada
if ($spEntityId === null) {
throw new SimpleSAML\Error\BadRequest('Missing <saml:Issuer> in <samlp:AttributeQuery>.');
}
$dstMetadata = $metadata->getMetadata($spEntityId, 'saml20-sp-remote');
foreach ($dstMetadata['AssertionConsumerService'] as $acs) {
if ($acs['Binding'] == SAML2\Constants::BINDING_PAOS) {
$endpointUrl = $acs['Location'];
}
};
if (!$endpointUrl) {
throw new SimpleSAML\Error\BadRequest('Missing PAOS endpointUrl in destination metadata.');
}

$spMetadata = $metadata->getMetaDataConfig($spEntityId, 'saml20-sp-remote');

$this->aaEntityId = $aaEntityId;
$this->aaMetadata = $aaMetadata;
$this->spEntityId = $spEntityId;
$this->spMetadata = $spMetadata;
$this->endpointUrl = $endpointUrl;
}

private function getAttributeNameFormat()
Expand Down Expand Up @@ -291,6 +300,7 @@ private function buildResponse($returnAttributes)
$response->setIssuer($this->aaEntityId);
$response->setInResponseTo($this->query->getId());
$response->setAssertions(array($assertion));
$response->setDestination($this->endpointUrl);
if ($this->signResponse) {
SimpleSAML\Module\saml\Message::addSign($this->aaMetadata, $this->spMetadata, $response);
}
Expand Down

0 comments on commit 4fb4dbb

Please sign in to comment.