Skip to content

Commit 947b94d

Browse files
committed
Add bcrypt support.
1 parent c4270e1 commit 947b94d

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

admin/schema.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@
396396
username C(32) NOTNULL DEFAULT \" '' \",
397397
realname C(64) NOTNULL DEFAULT \" '' \",
398398
email C(64) NOTNULL DEFAULT \" '' \",
399-
password C(32) NOTNULL DEFAULT \" '' \",
399+
password C(60) NOTNULL DEFAULT \" '' \",
400400
date_created T NOTNULL DEFAULT '" . db_null_date() . "',
401401
last_visit T NOTNULL DEFAULT '" . db_null_date() . "',
402402
enabled L NOTNULL DEFAULT \" '1' \",
@@ -423,7 +423,7 @@
423423
cookie_string
424424
)
425425
VALUES (
426-
'administrator', '', 'root@localhost', '63a9f0ea7bb98050796b649e85481845',
426+
'administrator', '', 'root@localhost', '" . password_hash('root', PASSWORD_BCRYPT) . "',
427427
$t_timestamp, $t_timestamp, '1', '0', 90,
428428
3, 0, 0, '"
429429
. md5( mt_rand( 0, mt_getrandmax() ) + mt_rand( 0, mt_getrandmax() ) ) . md5( time() )

core/authentication_api.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,10 @@ function auth_does_password_match( $p_user_id, $p_test_password ) {
776776
BASIC_AUTH,
777777
);
778778

779+
if ( BCRYPT == $t_configured_login_method ) {
780+
return password_verify( $p_test_password, $t_password );
781+
}
782+
779783
foreach( $t_login_methods as $t_login_method ) {
780784
# pass the stored password in as the salt
781785
if( auth_process_plain_password( $p_test_password, $t_password, $t_login_method ) === $t_password ) {
@@ -822,6 +826,9 @@ function auth_process_plain_password( $p_password, $p_salt = null, $p_method = n
822826
}
823827

824828
switch( $t_login_method ) {
829+
case BCRYPT:
830+
$t_processed_password = password_hash( $p_password, PASSWORD_BCRYPT );
831+
break;
825832
case CRYPT:
826833

827834
# a null salt is the same as no salt, which causes a salt to be generated

core/constant_inc.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161
define( 'LDAP', 4 );
162162
define( 'BASIC_AUTH', 5 );
163163
define( 'HTTP_AUTH', 6 );
164+
define( 'BCRYPT', 7 );
164165

165166
# file upload methods
166167
define( 'DISK', 1 );

0 commit comments

Comments
 (0)