Skip to content

Commit 6b4c729

Browse files
committed
23: if the auth.adminpassword is not hashed provide some insight
cpick 7aa5b1a
1 parent cb25ac5 commit 6b4c729

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

modules/core/src/Auth/Source/AdminPassword.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ protected function login(string $username, string $password): array
5858
throw new Error\Error(Error\ErrorCodes::WRONGUSERPASS);
5959
}
6060

61+
$pwinfo = password_get_info($adminPassword);
62+
if (!$pwinfo['algo']) {
63+
throw new Error\Error(Error\ErrorCodes::ADMINNOTHASHED);
64+
}
65+
6166
$hasher = new NativePasswordHasher();
6267
if (!$hasher->verify($adminPassword, $password)) {
6368
throw new Error\Error(Error\ErrorCodes::WRONGUSERPASS);

src/SimpleSAML/Error/ErrorCodes.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class ErrorCodes
3939
final public const NOTFOUND = 'NOTFOUND';
4040
final public const NOTFOUNDREASON = 'NOTFOUNDREASON';
4141
final public const NOTSET = 'NOTSET';
42+
final public const ADMINNOTHASHED = 'ADMINNOTHASHED';
4243
final public const NOTVALIDCERT = 'NOTVALIDCERT';
4344
final public const PROCESSASSERTION = 'PROCESSASSERTION';
4445
final public const PROCESSAUTHNREQUEST = 'PROCESSAUTHNREQUEST';
@@ -49,7 +50,6 @@ class ErrorCodes
4950
final public const UNKNOWNCERT = 'UNKNOWNCERT';
5051
final public const USERABORTED = 'USERABORTED';
5152
final public const WRONGUSERPASS = 'WRONGUSERPASS';
52-
5353
final public const KEY_TITLE = 'title';
5454
final public const KEY_DESCRIPTION = 'descr';
5555

@@ -85,6 +85,7 @@ final public function getDefaultTitles(): array
8585
self::NOTFOUND => Translate::noop('Page not found'),
8686
self::NOTFOUNDREASON => Translate::noop('Page not found'),
8787
self::NOTSET => Translate::noop('Password not set'),
88+
self::ADMINNOTHASHED => Translate::noop('Admin password not set to a hashed value'),
8889
self::NOTVALIDCERT => Translate::noop('Invalid certificate'),
8990
self::PROCESSASSERTION => Translate::noop('Error processing response from Identity Provider'),
9091
self::PROCESSAUTHNREQUEST => Translate::noop('Error processing request from Service Provider'),
@@ -189,6 +190,9 @@ final public function getDefaultDescriptions(): array
189190
self::NOTSET => Translate::noop("" .
190191
"The password in the configuration (auth.adminpassword) is not changed " .
191192
"from the default value. Please edit the configuration file."),
193+
self::ADMINNOTHASHED => Translate::noop("" .
194+
"The password in the configuration (auth.adminpassword) is not a hashed value. " .
195+
"Full details on how to fix this are supplied at https://github.com/simplesamlphp/simplesamlphp/wiki/Frequently-Asked-Questions-(FAQ)#failed-to-login-to-the-admin-page-with-and-error-message-admin-password-not-set-to-a-hashed-value"),
192196
self::NOTVALIDCERT => Translate::noop('You did not present a valid certificate.'),
193197
self::PROCESSASSERTION => Translate::noop('We did not accept the response sent from the Identity Provider.'),
194198
self::PROCESSAUTHNREQUEST => Translate::noop("" .

0 commit comments

Comments
 (0)