Skip to content
Snippets Groups Projects
Commit 068a2048 authored by Georg Gollmann's avatar Georg Gollmann
Browse files

Import the "required" flag of attributes

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.
parent d47bd324
No related branches found
No related tags found
No related merge requests found
...@@ -605,6 +605,9 @@ class SimpleSAML_Metadata_SAMLParser { ...@@ -605,6 +605,9 @@ class SimpleSAML_Metadata_SAMLParser {
if (array_key_exists('attributes', $spd)) { if (array_key_exists('attributes', $spd)) {
$ret['attributes'] = $spd['attributes']; $ret['attributes'] = $spd['attributes'];
} }
if (array_key_exists('attributes.required', $spd)) {
$ret['attributes.required'] = $spd['attributes.required'];
}
if (array_key_exists('attributes.NameFormat', $spd)) { if (array_key_exists('attributes.NameFormat', $spd)) {
$ret['attributes.NameFormat'] = $spd['attributes.NameFormat']; $ret['attributes.NameFormat'] = $spd['attributes.NameFormat'];
} }
...@@ -1073,9 +1076,14 @@ class SimpleSAML_Metadata_SAMLParser { ...@@ -1073,9 +1076,14 @@ class SimpleSAML_Metadata_SAMLParser {
$format = NULL; $format = NULL;
$sp['attributes'] = array(); $sp['attributes'] = array();
$sp['attributes.required'] = array();
foreach ($element->RequestedAttribute AS $child) { foreach ($element->RequestedAttribute AS $child) {
$attrname = $child->Name; $attrname = $child->Name;
$sp['attributes'][] = $attrname; $sp['attributes'][] = $attrname;
if ($child->isRequired) {
$sp['attributes.required'][] = $attrname;
}
if ($child->NameFormat !== NULL) { if ($child->NameFormat !== NULL) {
$attrformat = $child->NameFormat; $attrformat = $child->NameFormat;
...@@ -1097,6 +1105,9 @@ class SimpleSAML_Metadata_SAMLParser { ...@@ -1097,6 +1105,9 @@ class SimpleSAML_Metadata_SAMLParser {
*/ */
unset($sp['attributes']); unset($sp['attributes']);
} }
if (empty($sp['attributes.required'])) {
unset($sp['attributes.required']);
}
if ($format !== SAML2_Const::NAMEFORMAT_UNSPECIFIED && $format !== NULL) { if ($format !== SAML2_Const::NAMEFORMAT_UNSPECIFIED && $format !== NULL) {
$sp['attributes.NameFormat'] = $format; $sp['attributes.NameFormat'] = $format;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment