Skip to content

Commit

Permalink
Have exampleauth:UserPass have credentials stored under "users" key, …
Browse files Browse the repository at this point in the history
…instead of at top level of authsource config
  • Loading branch information
nathanjrobertson authored and tvdijen committed Mar 13, 2024
1 parent b05deb8 commit e1cc6a3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
16 changes: 9 additions & 7 deletions config/authsources.php.dist
Expand Up @@ -97,13 +97,15 @@ $config = [
//'remember.username.enabled' => false,
//'remember.username.checked' => false,

'student:studentpass' => [
'uid' => ['test'],
'eduPersonAffiliation' => ['member', 'student'],
],
'employee:employeepass' => [
'uid' => ['employee'],
'eduPersonAffiliation' => ['member', 'employee'],
'users' => [
'student:studentpass' => [
'uid' => ['test'],
'eduPersonAffiliation' => ['member', 'student'],
],
'employee:employeepass' => [
'uid' => ['employee'],
'eduPersonAffiliation' => ['member', 'employee'],
],
],
],
*/
Expand Down
16 changes: 9 additions & 7 deletions docs/simplesamlphp-idp.md
Expand Up @@ -83,13 +83,15 @@ In this setup, this file should contain a single entry:
$config = [
'example-userpass' => [
'exampleauth:UserPass',
'student:studentpass' => [
'uid' => ['student'],
'eduPersonAffiliation' => ['member', 'student'],
],
'employee:employeepass' => [
'uid' => ['employee'],
'eduPersonAffiliation' => ['member', 'employee'],
'users' => [
'student:studentpass' => [
'uid' => ['student'],
'eduPersonAffiliation' => ['member', 'student'],
],
'employee:employeepass' => [
'uid' => ['employee'],
'eduPersonAffiliation' => ['member', 'employee'],
],
],
],
];
Expand Down
8 changes: 6 additions & 2 deletions modules/exampleauth/src/Auth/Source/UserPass.php
Expand Up @@ -5,7 +5,8 @@
namespace SimpleSAML\Module\exampleauth\Auth\Source;

use Exception;
use SimpleSAML\{Error, Utils};
use SimpleSAML\Assert\Assert;
use SimpleSAML\{Error, Logger, Utils};
use SimpleSAML\Module\core\Auth\UserPassBase;

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

$this->users = [];

Assert::keyExists($config, 'users');
$config_users = $config['users'];

// Validate and parse our configuration
foreach ($config as $userpass => $attributes) {
foreach ($config_users as $userpass => $attributes) {
if (!is_string($userpass)) {
throw new Exception(
'Invalid <username>:<password> for authentication source ' . $this->authId . ': ' . $userpass
Expand Down

0 comments on commit e1cc6a3

Please sign in to comment.