From bda996f9d18d31f996cc0eab25ae4ccf9913008b Mon Sep 17 00:00:00 2001 From: Thomas Vanhaniemi <thomas.vanhaniemi@arcada.fi> Date: Thu, 1 Jun 2017 13:20:30 +0300 Subject: [PATCH] Added configuration support for index and isDefault on the generated md:AttributeConsumingService element Added two metadata configuration options attributes.index and attributes.isDefault to the Service Provider section that outputs to the md:AttributeConsumingService element. attributes.index overrides the index attribute value with another integer value specified. attributes.isDefault adds the isDefault attribute with the given boolean value, if the configuration option is specified. --- lib/SimpleSAML/Metadata/SAMLBuilder.php | 6 +++++- lib/SimpleSAML/Metadata/SAMLParser.php | 6 ++++++ modules/saml/docs/sp.md | 6 ++++++ modules/saml/www/sp/metadata.php | 8 ++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/SimpleSAML/Metadata/SAMLBuilder.php b/lib/SimpleSAML/Metadata/SAMLBuilder.php index 90451b713..1d5e7d32a 100644 --- a/lib/SimpleSAML/Metadata/SAMLBuilder.php +++ b/lib/SimpleSAML/Metadata/SAMLBuilder.php @@ -403,7 +403,11 @@ class SimpleSAML_Metadata_SAMLBuilder */ $attributeconsumer = new \SAML2\XML\md\AttributeConsumingService(); - $attributeconsumer->index = 0; + $attributeconsumer->index = $metadata->getInteger('attributes.index', 0); + + if ($metadata->hasValue('attributes.isDefault')) { + $attributeconsumer->isDefault = $metadata->getBoolean('attributes.isDefault', false); + } $attributeconsumer->ServiceName = $name; $attributeconsumer->ServiceDescription = $metadata->getLocalizedString('description', array()); diff --git a/lib/SimpleSAML/Metadata/SAMLParser.php b/lib/SimpleSAML/Metadata/SAMLParser.php index bd8886e68..9f55a243f 100644 --- a/lib/SimpleSAML/Metadata/SAMLParser.php +++ b/lib/SimpleSAML/Metadata/SAMLParser.php @@ -708,6 +708,12 @@ class SimpleSAML_Metadata_SAMLParser if (array_key_exists('attributes.NameFormat', $spd)) { $ret['attributes.NameFormat'] = $spd['attributes.NameFormat']; } + if (array_key_exists('attributes.index', $spd)) { + $ret['attributes.index'] = $spd['attributes.index']; + } + if (array_key_exists('attributes.isDefault', $spd)) { + $ret['attributes.isDefault'] = $spd['attributes.isDefault']; + } // add name & description if (array_key_exists('name', $spd)) { diff --git a/modules/saml/docs/sp.md b/modules/saml/docs/sp.md index 31def6f69..d3ca6791d 100644 --- a/modules/saml/docs/sp.md +++ b/modules/saml/docs/sp.md @@ -125,6 +125,12 @@ Options `attributes.NameFormat` : The `NameFormat` for the requested attributes. +`attributes.index` +: The `index` attribute that is set in the md:AttributeConsumingService element. Integer value that defaults to `0`. + +`attributes.isDefault` +: If present, sets the `isDefault` attribute in the md:AttributeConsumingService element. Boolean value that defaults to `false`. + `attributes.required` : If you have attributes added you can here specify which should be marked as required. : The attributes should still be present in `attributes`. diff --git a/modules/saml/www/sp/metadata.php b/modules/saml/www/sp/metadata.php index 9aa17835e..2bedb7756 100644 --- a/modules/saml/www/sp/metadata.php +++ b/modules/saml/www/sp/metadata.php @@ -148,6 +148,14 @@ if ($name !== null && !empty($attributes)) { if ($nameFormat !== null) { $metaArray20['attributes.NameFormat'] = $nameFormat; } + + if ($spconfig->hasValue('attributes.index')) { + $metaArray20['attributes.index'] = $spconfig->getInteger('attributes.index', 0); + } + + if ($spconfig->hasValue('attributes.isDefault')) { + $metaArray20['attributes.isDefault'] = $spconfig->getBoolean('attributes.isDefault', false); + } } // add organization info -- GitLab