Skip to content

Commit 5f46f4a

Browse files
author
Hans Zandbelt
committed
implement nameid stuff and extra check on sp entityid setting
git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1529 44740490-163a-0410-bde0-09ae8108e29a
1 parent 6f3daa4 commit 5f46f4a

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

modules/adfs/www/idp/prp.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,12 @@ function ADFS_PostResponse($url, $wresult, $wctx) {
190190

191191
$spentityid = $requestcache['Issuer'];
192192
$spmetadata = SimpleSAML_Configuration::getConfig('adfs-sp-remote.php');
193-
$spmetadata = SimpleSAML_Configuration::loadFromArray($spmetadata->getValue($spentityid));
193+
194+
$arr = $spmetadata->getValue($spentityid);
195+
if (!isset($arr)) {
196+
throw new Exception('Metadata for ADFS SP "' . $spentityid . '" could not be found in adfs-sp-remote.php!');
197+
}
198+
$spmetadata = SimpleSAML_Configuration::loadFromArray($arr);
194199

195200
$sp_name = $spmetadata->getValue('name', $spentityid);
196201

@@ -241,8 +246,17 @@ function ADFS_PostResponse($url, $wresult, $wctx) {
241246
if (array_key_exists('RelayState', $requestcache)) $relayState = $requestcache['RelayState'];
242247

243248
$nameid = $session->getNameID();
249+
$nameid = $nameid['value'];
250+
251+
$nameidattribute = $spmetadata->getValue('simplesaml.nameidattribute');
252+
if (isset($nameidattribute)) {
253+
if (!array_key_exists($nameidattribute, $attributes)) {
254+
throw new Exception('simplesaml.nameidattribute does not exist in resulting attribute set');
255+
}
256+
$nameid = $attributes[$nameidattribute][0];
257+
}
244258

245-
$response = ADFS_GenerateResponse($idpentityid, $spentityid, $nameid['value'], $attributes);
259+
$response = ADFS_GenerateResponse($idpentityid, $spentityid, $nameid, $attributes);
246260
$wresult = ADFS_SignResponse($response, $config->getPathValue('certdir') . $adfsconfig->getValue('key'), $config->getPathValue('certdir') . $adfsconfig->getValue('cert'));
247261

248262
ADFS_PostResponse($spmetadata->getValue('prp'), $wresult, $relayState);

0 commit comments

Comments
 (0)