Skip to content

Commit 11eeae5

Browse files
committed
Add bcrypt support.
1 parent c96c879 commit 11eeae5

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
@@ -831,6 +831,10 @@ function auth_does_password_match( $p_user_id, $p_test_password ) {
831831
BASIC_AUTH,
832832
);
833833

834+
if ( BCRYPT == $t_configured_login_method ) {
835+
return password_verify( $p_test_password, $t_password );
836+
}
837+
834838
foreach( $t_login_methods as $t_login_method ) {
835839
# pass the stored password in as the salt
836840
if( auth_process_plain_password( $p_test_password, $t_password, $t_login_method ) === $t_password ) {
@@ -884,6 +888,9 @@ function auth_process_plain_password( $p_password, $p_salt = null, $p_method = n
884888
}
885889

886890
switch( $t_login_method ) {
891+
case BCRYPT:
892+
$t_processed_password = password_hash( $p_password, PASSWORD_BCRYPT );
893+
break;
887894
case CRYPT:
888895

889896
# 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)