diff --git a/modules/saml2/lib/Auth/Source/SP.php b/modules/saml2/lib/Auth/Source/SP.php index b4ade68e225965aba412ffab0c706deded77c094..6da47d57a0c6824b3377eb77e2fc86b06f8ef677 100644 --- a/modules/saml2/lib/Auth/Source/SP.php +++ b/modules/saml2/lib/Auth/Source/SP.php @@ -127,6 +127,24 @@ class sspmod_saml2_Auth_Source_SP extends SimpleSAML_Auth_Source { } + /** + * Retrieve the NameIDFormat used by this SP. + * + * @return string NameIDFormat used by this SP. + */ + public function getNameIDFormat() { + + $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler(); + $spmeta = $metadata->getMetadata($this->entityID, 'saml20-sp-hosted'); + + if (array_key_exists('NameIDFormat', $spmeta)) { + return $spmeta['NameIDFormat']; + } else { + return 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient'; + } + } + + /** * Check if the IdP entity id is allowed to authenticate users for this authentication source. * diff --git a/modules/saml2/www/sp/metadata.php b/modules/saml2/www/sp/metadata.php index 74449495bb75b7dfb42c6486aacfe2df6699c333..77f542c93ed48413a00d3c5c463232f71ba617de 100644 --- a/modules/saml2/www/sp/metadata.php +++ b/modules/saml2/www/sp/metadata.php @@ -19,8 +19,10 @@ $entityId = $source->getEntityId(); $metaArray = array( 'AssertionConsumerService' => SimpleSAML_Module::getModuleURL('saml2/sp/acs.php'), 'SingleLogoutService' => SimpleSAML_Module::getModuleURL('saml2/sp/logout.php/' . $sourceId), + 'NameIDFormat' => $source->getNameIDFormat(), ); + $metaBuilder = new SimpleSAML_Metadata_SAMLBuilder($entityId); $metaBuilder->addMetadataSP20($metaArray);