@@ -779,6 +779,9 @@ private function _getAttributesByKeyName($keyName = "Name")
779779
780780 $ entries = $ this ->_queryAssertion ('/saml:AttributeStatement/saml:Attribute ' );
781781
782+ $ security = $ this ->_settings ->getSecurityData ();
783+ $ allowRepeatAttributeName = $ security ['allowRepeatAttributeName ' ];
784+
782785 /** @var $entry DOMNode */
783786 foreach ($ entries as $ entry ) {
784787 $ attributeKeyNode = $ entry ->attributes ->getNamedItem ($ keyName );
@@ -790,10 +793,12 @@ private function _getAttributesByKeyName($keyName = "Name")
790793 $ attributeKeyName = $ attributeKeyNode ->nodeValue ;
791794
792795 if (in_array ($ attributeKeyName , array_keys ($ attributes ))) {
793- throw new OneLogin_Saml2_ValidationError (
794- "Found an Attribute element with duplicated " .$ keyName ,
795- OneLogin_Saml2_ValidationError::DUPLICATED_ATTRIBUTE_NAME_FOUND
796- );
796+ if (!$ allowRepeatAttributeName ) {
797+ throw new OneLogin_Saml2_ValidationError (
798+ "Found an Attribute element with duplicated " .$ keyName ,
799+ OneLogin_Saml2_ValidationError::DUPLICATED_ATTRIBUTE_NAME_FOUND
800+ );
801+ }
797802 }
798803
799804 $ attributeValues = array ();
@@ -804,7 +809,11 @@ private function _getAttributesByKeyName($keyName = "Name")
804809 }
805810 }
806811
807- $ attributes [$ attributeKeyName ] = $ attributeValues ;
812+ if (in_array ($ attributeKeyName , array_keys ($ attributes ))) {
813+ $ attributes [$ attributeKeyName ] = array_merge ($ attributes [$ attributeKeyName ], $ attributeValues );
814+ } else {
815+ $ attributes [$ attributeKeyName ] = $ attributeValues ;
816+ }
808817 }
809818 return $ attributes ;
810819 }
0 commit comments