From 068a20487a908bff9d123a6e18426dd83e2a739e Mon Sep 17 00:00:00 2001 From: Georg Gollmann <georg.gollmann@tuwien.ac.at> Date: Thu, 25 Sep 2014 15:18:00 +0200 Subject: [PATCH] Import the "required" flag of attributes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pass the “required” status of requested attributes from XML metadata to metadata-generated/saml20-sp-remote.php. Required attributes are added to an “attributes.required” element. --- lib/SimpleSAML/Metadata/SAMLParser.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/SimpleSAML/Metadata/SAMLParser.php b/lib/SimpleSAML/Metadata/SAMLParser.php index d252af5bd..fcf2ee31e 100644 --- a/lib/SimpleSAML/Metadata/SAMLParser.php +++ b/lib/SimpleSAML/Metadata/SAMLParser.php @@ -605,6 +605,9 @@ class SimpleSAML_Metadata_SAMLParser { if (array_key_exists('attributes', $spd)) { $ret['attributes'] = $spd['attributes']; } + if (array_key_exists('attributes.required', $spd)) { + $ret['attributes.required'] = $spd['attributes.required']; + } if (array_key_exists('attributes.NameFormat', $spd)) { $ret['attributes.NameFormat'] = $spd['attributes.NameFormat']; } @@ -1073,9 +1076,14 @@ class SimpleSAML_Metadata_SAMLParser { $format = NULL; $sp['attributes'] = array(); + $sp['attributes.required'] = array(); foreach ($element->RequestedAttribute AS $child) { $attrname = $child->Name; $sp['attributes'][] = $attrname; + + if ($child->isRequired) { + $sp['attributes.required'][] = $attrname; + } if ($child->NameFormat !== NULL) { $attrformat = $child->NameFormat; @@ -1097,6 +1105,9 @@ class SimpleSAML_Metadata_SAMLParser { */ unset($sp['attributes']); } + if (empty($sp['attributes.required'])) { + unset($sp['attributes.required']); + } if ($format !== SAML2_Const::NAMEFORMAT_UNSPECIFIED && $format !== NULL) { $sp['attributes.NameFormat'] = $format; -- GitLab