-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Config] Add password algorithm selector #9468
base: main
Are you sure you want to change the base?
[Config] Add password algorithm selector #9468
Conversation
@@ -88,6 +88,14 @@ class Configuration extends \NDB_Form | |||
'emergency' => 'Emergency', | |||
]; | |||
|
|||
$this->tpl_data['password_algos'] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use https://www.php.net/manual/en/function.password-algos.php (and add a "Default" option)
I'm not really sure what the point of having the blank option here is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That function doesn't output usable strings for the password_hash function unfortunately. It gives values such as: '2y','argon2i, 'argon2id'
, but password_hash uses, 'PASSWORD_DEFAULT','PASSWORD_BCRYPT', 'PASSWORD_ARGON2I', and 'PASSWORD_ARGON2ID'
I will remove the blank option though. It was just there in-case somehow a non-usable value was saved so it doesn't show PASSWORD_DEFAULT instead. But it probably just makes it confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PASSWORD_DEFAULT/PASSWORD_BCRYPT/etc are just built in constants with those values.
$ php -a
Interactive shell
php > print PASSWORD_DEFAULT;
2y
php > print PASSWORD_ARGON2I;
argon2i
php > print_r(password_algos());
Array
(
[0] => 2y
[1] => argon2i
[2] => argon2id
)
php > print password_hash('test', 'argon2i');
$argon2i$v=19$m=65536,t=4,p=1$WlBObVNleHU0RHVCMG9DTw$3jZ/HN8N4r6YERoJJbMGup/d8rebjUZ72lYZcbTsjno
php >
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh sweet, thanks!
@kongtiaowang I can't seem to get the tests to work in the Password class due to the addition of a getSetting from the Config table in Password. How can I setup the mock table in the test to have a value for Config? |
Brief summary of changes
Testing instructions (if applicable)