From e5c4b99d957a0241edee512141e0574f8cf6810f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaime=20P=C3=A9rez=20Crespo?= <jaime.perez@uninett.no>
Date: Mon, 9 Dec 2013 14:23:51 +0000
Subject: [PATCH] Take into account the NameIDFormat specified in idp-hosted
 metadata when no such option is configured for an SP.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3312 44740490-163a-0410-bde0-09ae8108e29a
---
 modules/saml/lib/IdP/SAML2.php | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/modules/saml/lib/IdP/SAML2.php b/modules/saml/lib/IdP/SAML2.php
index 3b33c7b34..e7615a950 100644
--- a/modules/saml/lib/IdP/SAML2.php
+++ b/modules/saml/lib/IdP/SAML2.php
@@ -865,7 +865,10 @@ class sspmod_saml_IdP_SAML2 {
 
 		if ($nameIdFormat === NULL || !isset($state['saml:NameID'][$nameIdFormat])) {
 			/* Either not set in request, or not set to a format we supply. Fall back to old generation method. */
-			$nameIdFormat = $spMetadata->getString('NameIDFormat', 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient');
+			$nameIdFormat = $spMetadata->getString('NameIDFormat', NULL);
+			if ($nameIdFormat === NULL) {
+				$nameIdFormat = $idpMetadata->getString('NameIDFormat', SAML2_Const::NAMEID_TRANSIENT);
+			}
 		}
 
 		if (isset($state['saml:NameID'][$nameIdFormat])) {
-- 
GitLab