diff --git a/src/Saml2/Metadata.php b/src/Saml2/Metadata.php index bac761cf..91cb0424 100644 --- a/src/Saml2/Metadata.php +++ b/src/Saml2/Metadata.php @@ -38,10 +38,11 @@ class Metadata * @param array $contacts Contacts info * @param array $organization Organization ingo * @param array $attributes + * @param bool $ignoreValidUntil exclude the validUntil tag from metadata * * @return string SAML Metadata XML */ - public static function builder($sp, $authnsign = false, $wsign = false, $validUntil = null, $cacheDuration = null, $contacts = array(), $organization = array(), $attributes = array()) + public static function builder($sp, $authnsign = false, $wsign = false, $validUntil = null, $cacheDuration = null, $contacts = array(), $organization = array(), $attributes = array(), $ignoreValidUntil = false) { if (!isset($validUntil)) { @@ -161,27 +162,37 @@ public static function builder($sp, $authnsign = false, $wsign = false, $validUn $requestedAttributeStr = implode(PHP_EOL, $requestedAttributeData); $strAttributeConsumingService = << + + {$sp['attributeConsumingService']['serviceName']} {$attrCsDesc}{$requestedAttributeStr} METADATA_TEMPLATE; } + if ($ignoreValidUntil) { + $timeStr = << {$sls} {$sp['NameIDFormat']} - {$strAttributeConsumingService} + index="1" />{$strAttributeConsumingService} {$strOrganization}{$strContacts} METADATA_TEMPLATE; diff --git a/tests/src/OneLogin/Saml2/MetadataTest.php b/tests/src/OneLogin/Saml2/MetadataTest.php index 290ff9ff..3849b10f 100644 --- a/tests/src/OneLogin/Saml2/MetadataTest.php +++ b/tests/src/OneLogin/Saml2/MetadataTest.php @@ -52,6 +52,7 @@ public function testBuilder() $this->assertStringContainsString('sp_test', $metadata); $this->assertStringContainsString('', $metadata); $this->assertStringContainsString('technical_name', $metadata); + $this->assertStringContainsString('validUntil', $metadata); $security['authnRequestsSigned'] = true; $security['wantAssertionsSigned'] = true; @@ -66,6 +67,9 @@ public function testBuilder() $this->assertStringNotContainsString('assertStringNotContainsString(' Location="http://stuff.com/endpoints/endpoints/sls.php"/>', $metadata2); + + $metadata3 = Metadata::builder($spData, $security['authnRequestsSigned'], $security['wantAssertionsSigned'], null, null, $contacts, $organization, array(), true); + $this->assertStringNotContainsString('validUntil=', $metadata3); } /**