Skip to content

Commit 0995034

Browse files
author
Loïc Dachary
committed
[SECURITY] default to pbkdf2 with 320,000 iterations
Conflicts: modules/auth/password/hash/setting.go modules/auth/password/hash/setting_test.go
1 parent c701776 commit 0995034

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

custom/conf/app.example.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,8 @@ INTERNAL_TOKEN=
439439
;;Classes include "lower,upper,digit,spec"
440440
;PASSWORD_COMPLEXITY = off
441441
;;
442-
;; Password Hash algorithm, either "argon2", "pbkdf2", "scrypt" or "bcrypt"
443-
;PASSWORD_HASH_ALGO = pbkdf2
442+
;; Password Hash algorithm, either "argon2", "pbkdf2"/"pbkdf2_v2", "pbkdf2_hi", "scrypt" or "bcrypt"
443+
;PASSWORD_HASH_ALGO = pbkdf2_hi
444444
;;
445445
;; Set false to allow JavaScript to read CSRF cookie
446446
;CSRF_COOKIE_HTTP_ONLY = true

modules/auth/password/hash/setting.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33

44
package hash
55

6-
const DefaultHashAlgorithmName = "pbkdf2"
6+
// DefaultHashAlgorithmName represents the default value of PASSWORD_HASH_ALGO
7+
// configured in app.ini.
8+
//
9+
// It is NOT the same and does NOT map to the defaultEmptyHashAlgorithmSpecification.
10+
//
11+
// It will be dealiased as per aliasAlgorithmNames whereas
12+
// defaultEmptyHashAlgorithmSpecification does not undergo dealiasing.
13+
const DefaultHashAlgorithmName = "pbkdf2_hi"
714

815
var DefaultHashAlgorithm *PasswordHashAlgorithm
916

modules/auth/password/hash/setting_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ func TestCheckSettingPasswordHashAlgorithm(t *testing.T) {
2828
})
2929
}
3030

31-
t.Run("pbkdf2_v2 is the default when default password hash algorithm is empty", func(t *testing.T) {
31+
t.Run("pbkdf2_hi is the default when default password hash algorithm is empty", func(t *testing.T) {
3232
emptyConfig, emptyAlgo := SetDefaultPasswordHashAlgorithm("")
33-
pbkdf2v2Config, pbkdf2v2Algo := SetDefaultPasswordHashAlgorithm("pbkdf2_v2")
33+
pbkdf2hiConfig, pbkdf2hiAlgo := SetDefaultPasswordHashAlgorithm("pbkdf2_hi")
3434

35-
assert.Equal(t, pbkdf2v2Config, emptyConfig)
36-
assert.Equal(t, pbkdf2v2Algo.Name, emptyAlgo.Name)
35+
assert.Equal(t, pbkdf2hiConfig, emptyConfig)
36+
assert.Equal(t, pbkdf2hiAlgo.Name, emptyAlgo.Name)
3737
})
3838
}

0 commit comments

Comments
 (0)