Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit 9324320

Browse files
Merge pull request #31 from melanger/patch-5
* Limit copy-paste in DatabaseCommand.php * read spName only if present
2 parents b658c5b + 6b2fa12 commit 9324320

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
1111
- Update README.md
1212
- describe setup for modes PROXY/SP/IDP
1313
- change array notation from `array()` to `[]`
14+
- Read spName from $request only if present
1415

1516
## [v3.1.0]
1617
#### Added

lib/Auth/Process/DatabaseCommand.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,25 @@ public static function insertLogin(&$request, &$date)
2020
$identityProvidersMapTableName = $databaseConnector->getIdentityProvidersMapTableName();
2121
$serviceProvidersMapTableName = $databaseConnector->getServiceProvidersMapTableName();
2222

23+
if (!in_array($databaseConnector->getMode(), ['PROXY', 'IDP', 'SP'])) {
24+
throw new Exception('Unknown mode is set. Mode has to be one of the following: PROXY, IDP, SP.');
25+
}
26+
27+
if ($databaseConnector->getMode() !== 'IDP') {
28+
$idpName = $request['Attributes']['sourceIdPName'][0];
29+
$idpEntityID = $request['saml:sp:IdP'];
30+
}
31+
if ($databaseConnector->getMode() !== 'SP') {
32+
$spEntityId = $request['Destination']['entityid'];
33+
$spName = isset($request['Destination']['name']) ? $request['Destination']['name']['en'] : '';
34+
}
35+
2336
if ($databaseConnector->getMode() === 'IDP') {
2437
$idpName = $databaseConnector->getIdpName();
2538
$idpEntityID = $databaseConnector->getIdpEntityId();
26-
$spEntityId = $request['Destination']['entityid'];
27-
$spName = $request['Destination']['name']['en'];
2839
} elseif ($databaseConnector->getMode() === 'SP') {
29-
$idpName = $request['Attributes']['sourceIdPName'][0];
30-
$idpEntityID = $request['saml:sp:IdP'];
3140
$spEntityId = $databaseConnector->getSpEntityId();
3241
$spName = $databaseConnector->getSpName();
33-
} elseif ($databaseConnector->getMode() === 'PROXY') {
34-
$idpName = $request['Attributes']['sourceIdPName'][0];
35-
$idpEntityID = $request['saml:sp:IdP'];
36-
$spEntityId = $request['Destination']['entityid'];
37-
$spName = $request['Destination']['name']['en'];
38-
} else {
39-
throw new Exception('Unknown mode is set. Mode has to be one of the following: PROXY, IDP, SP.');
4042
}
4143

4244
$year = $date->format('Y');

0 commit comments

Comments
 (0)