Skip to content
Snippets Groups Projects
Commit 85fa4591 authored by Olav Morken's avatar Olav Morken
Browse files

Ignore cacheDuration when evaluating validity of metadata.

Thanks to Thijs Kinkhorst for providing this patch.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3034 44740490-163a-0410-bde0-09ae8108e29a
parent f2fa425a
Branches
Tags
No related merge requests found
...@@ -224,4 +224,8 @@ In config.php: ...@@ -224,4 +224,8 @@ In config.php:
), ),
Metadata cacheDuration
----------------------
SAML metadata may supply a cacheDuration attribute which indicates the maxium time to cache metadata. Because this module is run from cron, it cannot influence how often it is run and enfore this attribute by itself. Take care that you run metarefresh from cron at least as often as the shortest cacheDuration in your metadata sources.
...@@ -342,11 +342,8 @@ class SimpleSAML_Metadata_SAMLParser { ...@@ -342,11 +342,8 @@ class SimpleSAML_Metadata_SAMLParser {
/** /**
* Determine how long a given element can be cached. * Determine how long a given element can be cached.
* *
* This function looks for the 'cacheDuration' and 'validUntil' attributes to determine * This function looks for the 'validUntil' attribute to determine
* how long a given XML-element is valid. It returns this as na unix timestamp. * how long a given XML-element is valid. It returns this as a unix timestamp.
*
* If both the 'cacheDuration' and 'validUntil' attributes are present, the shorter of them
* will be returned.
* *
* @param mixed $element The element we should determine the expiry time of. * @param mixed $element The element we should determine the expiry time of.
* @param int|NULL $maxExpireTime The maximum expiration time. * @param int|NULL $maxExpireTime The maximum expiration time.
...@@ -354,22 +351,13 @@ class SimpleSAML_Metadata_SAMLParser { ...@@ -354,22 +351,13 @@ class SimpleSAML_Metadata_SAMLParser {
* limit is set for the element. * limit is set for the element.
*/ */
private static function getExpireTime($element, $maxExpireTime) { private static function getExpireTime($element, $maxExpireTime) {
/* validUntil may be NULL */
$expire = $element->validUntil;
if ($element->cacheDuration !== NULL) { if ( $maxExpireTime !== NULL && ($expire === NULL || $maxExpireTime < $expire) ) {
$expire = SimpleSAML_Utilities::parseDuration($element->cacheDuration, time());
if ($maxExpireTime !== NULL && $maxExpireTime < $expire) {
$expire = $maxExpireTime;
}
} else {
$expire = $maxExpireTime; $expire = $maxExpireTime;
} }
if ($element->validUntil !== NULL) {
if ($expire === NULL || $expire > $element->validUntil) {
$expire = $element->validUntil;
}
}
return $expire; return $expire;
} }
......
...@@ -209,19 +209,6 @@ class sspmod_aggregator2_EntitySource { ...@@ -209,19 +209,6 @@ class sspmod_aggregator2_EntitySource {
$expires = $this->metadata->validUntil; $expires = $this->metadata->validUntil;
} }
if ($this->metadata->cacheDuration !== NULL) {
try {
$durationTo = SimpleSAML_Utilities::parseDuration($this->metadata->cacheDuration);
} catch (Exception $e) {
SimpleSAML_Logger::warning($this->logLoc . 'Invalid cacheDuration in metadata from ' .
var_export($this->url, TRUE) . ': ' . var_export($this->metadata->cacheDuration, TRUE));
return;
}
if ($durationTo < $expires) {
$expires = $durationTo;
}
}
$metadataSerialized = serialize($this->metadata); $metadataSerialized = serialize($this->metadata);
$this->aggregator->addCacheItem($this->cacheId, $metadataSerialized, $expires, $this->cacheTag); $this->aggregator->addCacheItem($this->cacheId, $metadataSerialized, $expires, $this->cacheTag);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment