Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions app/config/parameters.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ parameters:
## Add RequestedAttributes to the AttributeConsumingService of the SP Proxy metadata of Engineblock, default is all
## Options are 'all' (optional and required attributes), 'required' (only required attributes) or 'none'
metadata_add_requested_attributes: all
## The number of seconds a Metadata document is deemed valid (default 24h)
metadata_expiration_time: 86400

##########################################################################################
## PHP SETTINGS
Expand Down
8 changes: 5 additions & 3 deletions src/OpenConext/EngineBlock/Xml/MetadataRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class MetadataRenderer
/**
* The number of seconds a Metadata document is deemed valid
*/
const METADATA_EXPIRATION_TIME = 86400;
private $metadataExpirationTime;

/**
* @var Environment
Expand Down Expand Up @@ -83,7 +83,8 @@ public function __construct(
KeyPairFactory $keyPairFactory,
DocumentSigner $documentSigner,
TimeProvider $timeProvider,
string $addRequestedAttributes
string $addRequestedAttributes,
int $metadataExpirationTime
) {
$this->languageSupportProvider = $languageSupportProvider;
$this->twig = $twig;
Expand All @@ -92,6 +93,7 @@ public function __construct(
$this->documentSigner = $documentSigner;
$this->timeProvider = $timeProvider;
$this->addRequestedAttributes = $addRequestedAttributes;
$this->metadataExpirationTime = $metadataExpirationTime;
}

public function fromServiceProviderEntity(ServiceProviderEntityInterface $sp, string $keyId) : string
Expand Down Expand Up @@ -190,6 +192,6 @@ private function renderMetadataXmlIdentityProviderCollection(IdentityProviderEnt

private function getValidUntil(): string
{
return $this->timeProvider->timestamp(self::METADATA_EXPIRATION_TIME);
return $this->timeProvider->timestamp($this->metadataExpirationTime);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ services:
- "@OpenConext\\EngineBlock\\Xml\\DocumentSigner"
- "@engineblock.service.time_provider"
- "%metadata_add_requested_attributes%"
- "%metadata_expiration_time%"

OpenConext\EngineBlock\Xml\MetadataProvider:
arguments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ private function buildMetadataRenderer(string $addRequestedAttributes)
$keyPairFactory,
$documentSigner,
new TimeProvider(),
$addRequestedAttributes
$addRequestedAttributes,
86400
Comment on lines +348 to +349
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from fixing the test by passing the new parameter, it might be very useful to add a couple of tests that verify the expiration time ends up correctly in the metadata?

);
}

Expand Down