Skip to content

Commit efbee63

Browse files
committed
Modification to permit the automatic metadata creation of an SP to produce a friendlyName for RequestedAttributes.
The current code works as follows. If authsources.php contains the following configuration: 'attributes' => array( 'eppn' => 'urn:oid:1.3.6.1.4.1.5923.1.1.1.6', 'mail' => 'urn:oid:0.9.2342.19200300.100.1.3', 'o' => 'urn:oid:2.5.4.10', 'cn' => 'urn:oid:2.5.4.3', 'givenName' => 'urn:oid:2.5.4.42', ), the metadata generator will produce the XML Metadata as follows: <md:RequestedAttribute FriendlyName="eppn" Name="urn:oid:1.3.6.1.4.1.5923.1.1.1.6" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" /> <md:RequestedAttribute FriendlyName="mail" Name="urn:oid:0.9.2342.19200300.100.1.3" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" /> <md:RequestedAttribute FriendlyName="o" Name="urn:oid:2.5.4.10" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" /> <md:RequestedAttribute FriendlyName="cn" Name="urn:oid:2.5.4.3" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" /> <md:RequestedAttribute FriendlyName="givenName" Name="urn:oid:2.5.4.42" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" />
1 parent 3d1d8af commit efbee63

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

config-templates/authsources.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@
4747
* Please refer to the hosted SP configuration reference for more information.
4848
*/
4949
//'signature.algorithm' => 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256',
50+
51+
/*
52+
// The attributes parameter must contain an array of desired attributes by the SP.
53+
// The attributes can be expresed as an array of names or as an associative array
54+
// in the form of 'friendlyName' => 'name'.
55+
// The metadata will then be created as follows:
56+
// <md:RequestedAttribute FriendlyName="friendlyName" Name="name" />
57+
'attributes' => array(
58+
'attrname' => 'urn:oid:x.x.x.x',
59+
),
60+
'attributes.required' => array (
61+
'urn:oid:x.x.x.x',
62+
),
63+
*/
5064
),
5165

5266

lib/SimpleSAML/Metadata/SAMLBuilder.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,12 @@ private function addAttributeConsumingService(SAML2_XML_md_SPSSODescriptor $spDe
370370
$attributeconsumer->ServiceDescription = $metadata->getLocalizedString('description', array());
371371

372372
$nameFormat = $metadata->getString('attributes.NameFormat', SAML2_Const::NAMEFORMAT_UNSPECIFIED);
373-
foreach ($attributes as $attribute) {
373+
foreach ($attributes as $friendlyName => $attribute) {
374374
$t = new SAML2_XML_md_RequestedAttribute();
375375
$t->Name = $attribute;
376+
if (!is_int($friendlyName)) {
377+
$t->FriendlyName = $friendlyName;
378+
}
376379
if ($nameFormat !== SAML2_Const::NAMEFORMAT_UNSPECIFIED) {
377380
$t->NameFormat = $nameFormat;
378381
}

0 commit comments

Comments
 (0)