Skip to content

Commit 44507da

Browse files
authored
Add controllers for the saml-module (simplesamlphp#1623)
Add some controllers + tests
1 parent a75b498 commit 44507da

32 files changed

Lines changed: 1721 additions & 796 deletions

composer.lock

Lines changed: 159 additions & 160 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/simplesamlphp-artifact-idp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ In general, that should look something like:
6868
'AssertionConsumerService' => array (
6969
[
7070
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
71-
'Location' => 'https://sp.example.org/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp',
71+
'Location' => 'https://sp.example.org/simplesaml/module.php/saml/sp/assertionConsumerService/default-sp',
7272
'index' => 0,
7373
],
7474
[
7575
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact',
76-
'Location' => 'https://sp.example.org/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp',
76+
'Location' => 'https://sp.example.org/simplesaml/module.php/saml/sp/assertionConsumerService/default-sp',
7777
'index' => 2,
7878
],
7979
),

docs/simplesamlphp-hok-idp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ In general, this should look like the following code:
6464
'AssertionConsumerService' => array (
6565
[
6666
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
67-
'Location' => 'https://sp.example.org/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp',
67+
'Location' => 'https://sp.example.org/simplesaml/module.php/saml/sp/assertionConsumerService/default-sp',
6868
'index' => 0,
6969
],
7070
[
7171
'Binding' => 'urn:oasis:names:tc:SAML:2.0:profiles:holder-of-key:SSO:browser',
72-
'Location' => 'https://sp.example.org/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp',
72+
'Location' => 'https://sp.example.org/simplesaml/module.php/saml/sp/assertionConsumerService/default-sp',
7373
'index' => 4,
7474
],
7575
),

docs/simplesamlphp-idp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ This is a minimal example of a `metadata/saml20-sp-remote.php` metadata file for
191191

192192
<?php
193193
$metadata['https://sp.example.org/simplesaml/module.php/saml/sp/metadata.php/default-sp'] = [
194-
'AssertionConsumerService' => 'https://sp.example.org/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp',
195-
'SingleLogoutService' => 'https://sp.example.org/simplesaml/module.php/saml/sp/saml2-logout.php/default-sp',
194+
'AssertionConsumerService' => 'https://sp.example.org/simplesaml/module.php/saml/sp/assertionConsumerService/default-sp',
195+
'SingleLogoutService' => 'https://sp.example.org/simplesaml/module.php/saml/sp/singleLogoutService/default-sp',
196196
];
197197

198198
Note that the URI in the entityID and the URLs to the AssertionConsumerService and SingleLogoutService endpoints change between different service providers.

lib/SimpleSAML/Configuration.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,8 @@ public function getArrayizeString(string $name): array
10151015
* @param string[]|null $default A default value which will be returned if the option isn't found.
10161016
* The default value can be null or an array of strings.
10171017
*
1018-
* @return string[]|null The option with the given name, or $default if the option isn't found and $default is specified.
1018+
* @return string[]|null The option with the given name, or $default if the option isn't found
1019+
* and $default is specified.
10191020
* @psalm-return ($default is set ? array|null : array)
10201021
*
10211022
* @throws \SimpleSAML\Assert\AssertionFailedException If the option is not a string or an array of strings.
@@ -1082,7 +1083,10 @@ public function getOptionalConfigItem(string $name, ?array $default): ?Configura
10821083
{
10831084
$ret = $this->getOptionalArray($name, $default);
10841085

1085-
return ($ret === null) ? null : self::loadFromArray($ret, $this->location . '[' . var_export($name, true) . ']');
1086+
if ($ret !== null) {
1087+
return self::loadFromArray($ret, $this->location . '[' . var_export($name, true) . ']');
1088+
}
1089+
return null;
10861090
}
10871091

10881092

lib/SimpleSAML/Database.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ private function __construct(Configuration $config)
105105
);
106106
}
107107
// connect to any configured secondaries, preserving legacy config option
108-
$secondaries = $config->getOptionalArray('database.secondaries', $config->getOptionalArray('database.slaves', []));
108+
$secondaries = $config->getOptionalArray(
109+
'database.secondaries',
110+
$config->getOptionalArray('database.slaves', [])
111+
);
109112
foreach ($secondaries as $secondary) {
110113
array_push(
111114
$this->dbSecondaries,
@@ -140,7 +143,10 @@ private static function generateInstanceId(Configuration $config): string
140143
],
141144

142145
// TODO: deprecated: the "database.slave" terminology is preserved here for backwards compatibility.
143-
'secondaries' => $config->getOptionalArray('database.secondaries', $config->getOptionalArray('database.slaves', [])),
146+
'secondaries' => $config->getOptionalArray(
147+
'database.secondaries',
148+
$config->getOptionalArray('database.slaves', [])
149+
),
144150
];
145151

146152
return sha1(serialize($assembledConfig));

lib/SimpleSAML/Logger/SyslogLoggingHandler.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ class SyslogLoggingHandler implements LoggingHandlerInterface
2727
*/
2828
public function __construct(Configuration $config)
2929
{
30-
$facility = $config->getOptionalInteger('logging.facility', defined('LOG_LOCAL5') ? constant('LOG_LOCAL5') : LOG_USER);
30+
$facility = $config->getOptionalInteger(
31+
'logging.facility',
32+
defined('LOG_LOCAL5') ? constant('LOG_LOCAL5') : LOG_USER
33+
);
3134

3235
// Remove any non-printable characters before storing
3336
$processname = preg_replace(

lib/SimpleSAML/XHTML/IdPDisco.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,27 @@
44

55
namespace SimpleSAML\XHTML;
66

7+
use Exception;
78
use SimpleSAML\Assert\Assert;
89
use SimpleSAML\Configuration;
910
use SimpleSAML\Logger;
1011
use SimpleSAML\Metadata\MetaDataStorageHandler;
1112
use SimpleSAML\Session;
1213
use SimpleSAML\Utils;
1314

15+
use function array_fill_keys;
16+
use function array_intersect_key;
17+
use function array_intersect;
18+
use function array_key_exists;
19+
use function array_keys;
20+
use function array_merge;
21+
use function htmlspecialchars;
22+
use function preg_match;
23+
use function sizeof;
24+
use function strcasecmp;
25+
use function urldecode;
26+
use function usort;
27+
1428
/**
1529
* This class implements a generic IdP discovery service, for use in various IdP
1630
* discovery service pages. This should reduce code duplication.
@@ -128,7 +142,7 @@ public function __construct(array $metadataSets, string $instance)
128142

129143
// standard discovery service parameters
130144
if (!array_key_exists('entityID', $_GET)) {
131-
throw new \Exception('Missing parameter: entityID');
145+
throw new Exception('Missing parameter: entityID');
132146
} else {
133147
$this->spEntityId = $_GET['entityID'];
134148
}
@@ -142,7 +156,7 @@ public function __construct(array $metadataSets, string $instance)
142156
$this->log('returnIdParam initially set to [' . $this->returnIdParam . ']');
143157

144158
if (!array_key_exists('return', $_GET)) {
145-
throw new \Exception('Missing parameter: return');
159+
throw new Exception('Missing parameter: return');
146160
} else {
147161
$httpUtils = new Utils\HTTP();
148162
$this->returnURL = $httpUtils->checkURLAllowed($_GET['return']);
@@ -251,7 +265,7 @@ protected function validateIdP(?string $idp): ?string
251265
try {
252266
$this->metadata->getMetaData($idp, $metadataSet);
253267
return $idp;
254-
} catch (\Exception $e) {
268+
} catch (Exception $e) {
255269
// continue
256270
}
257271
}
@@ -584,7 +598,7 @@ public function handleRequest(): void
584598
$templateFile = 'selectidp-links.twig';
585599
break;
586600
default:
587-
throw new \Exception('Invalid value for the \'idpdisco.layout\' option.');
601+
throw new Exception('Invalid value for the \'idpdisco.layout\' option.');
588602
}
589603

590604
$t = new Template($this->config, $templateFile);

metadata-templates/saml20-sp-remote.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
* Example SimpleSAMLphp SAML 2.0 SP
1111
*/
1212
$metadata['https://saml2sp.example.org'] = [
13-
'AssertionConsumerService' => 'https://saml2sp.example.org/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp',
14-
'SingleLogoutService' => 'https://saml2sp.example.org/simplesaml/module.php/saml/sp/saml2-logout.php/default-sp',
13+
'AssertionConsumerService' => 'https://saml2sp.example.org/simplesaml/module.php/saml/sp/assertionConsumerService/default-sp',
14+
'SingleLogoutService' => 'https://saml2sp.example.org/simplesaml/module.php/saml/sp/singleLogoutService/default-sp',
1515
];
1616

1717
/*

modules/admin/lib/Controller/Federation.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,10 @@ private function getHostedSP(): array
331331
// get the name
332332
$name = $source->getMetadata()->getOptionalLocalizedString(
333333
'name',
334-
$source->getMetadata()->getOptionalLocalizedString('OrganizationDisplayName', ['en' => $source->getAuthId()])
334+
$source->getMetadata()->getOptionalLocalizedString(
335+
'OrganizationDisplayName',
336+
['en' => $source->getAuthId()]
337+
)
335338
);
336339

337340
$builder = new SAMLBuilder($source->getEntityId());

0 commit comments

Comments
 (0)