Skip to content

Commit e1cc6a3

Browse files
nathanjrobertsontvdijen
authored andcommitted
Have exampleauth:UserPass have credentials stored under "users" key, instead of at top level of authsource config
1 parent b05deb8 commit e1cc6a3

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

config/authsources.php.dist

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,15 @@ $config = [
9797
//'remember.username.enabled' => false,
9898
//'remember.username.checked' => false,
9999

100-
'student:studentpass' => [
101-
'uid' => ['test'],
102-
'eduPersonAffiliation' => ['member', 'student'],
103-
],
104-
'employee:employeepass' => [
105-
'uid' => ['employee'],
106-
'eduPersonAffiliation' => ['member', 'employee'],
100+
'users' => [
101+
'student:studentpass' => [
102+
'uid' => ['test'],
103+
'eduPersonAffiliation' => ['member', 'student'],
104+
],
105+
'employee:employeepass' => [
106+
'uid' => ['employee'],
107+
'eduPersonAffiliation' => ['member', 'employee'],
108+
],
107109
],
108110
],
109111
*/

docs/simplesamlphp-idp.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,15 @@ In this setup, this file should contain a single entry:
8383
$config = [
8484
'example-userpass' => [
8585
'exampleauth:UserPass',
86-
'student:studentpass' => [
87-
'uid' => ['student'],
88-
'eduPersonAffiliation' => ['member', 'student'],
89-
],
90-
'employee:employeepass' => [
91-
'uid' => ['employee'],
92-
'eduPersonAffiliation' => ['member', 'employee'],
86+
'users' => [
87+
'student:studentpass' => [
88+
'uid' => ['student'],
89+
'eduPersonAffiliation' => ['member', 'student'],
90+
],
91+
'employee:employeepass' => [
92+
'uid' => ['employee'],
93+
'eduPersonAffiliation' => ['member', 'employee'],
94+
],
9395
],
9496
],
9597
];

modules/exampleauth/src/Auth/Source/UserPass.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
namespace SimpleSAML\Module\exampleauth\Auth\Source;
66

77
use Exception;
8-
use SimpleSAML\{Error, Utils};
8+
use SimpleSAML\Assert\Assert;
9+
use SimpleSAML\{Error, Logger, Utils};
910
use SimpleSAML\Module\core\Auth\UserPassBase;
1011

1112
use function array_key_exists;
@@ -46,8 +47,11 @@ public function __construct(array $info, array $config)
4647

4748
$this->users = [];
4849

50+
Assert::keyExists($config, 'users');
51+
$config_users = $config['users'];
52+
4953
// Validate and parse our configuration
50-
foreach ($config as $userpass => $attributes) {
54+
foreach ($config_users as $userpass => $attributes) {
5155
if (!is_string($userpass)) {
5256
throw new Exception(
5357
'Invalid <username>:<password> for authentication source ' . $this->authId . ': ' . $userpass

0 commit comments

Comments
 (0)