mirror of
https://github.com/kopia/kopia.git
synced 2025-12-23 22:57:50 -05:00
refactor(server): relocate user.getPasswordHashAlgorithm (#4101)
Trivial code movement, no effective code changes.
This commit is contained in:
@@ -1,18 +1,4 @@
|
||||
package user
|
||||
|
||||
import "github.com/pkg/errors"
|
||||
|
||||
// defaultPasswordHashVersion is the default scheme used for user password hashing.
|
||||
const defaultPasswordHashVersion = ScryptHashVersion
|
||||
|
||||
// getPasswordHashAlgorithm returns the password hash algorithm given a version.
|
||||
func getPasswordHashAlgorithm(passwordHashVersion int) (string, error) {
|
||||
switch passwordHashVersion {
|
||||
case ScryptHashVersion:
|
||||
return scryptHashAlgorithm, nil
|
||||
case Pbkdf2HashVersion:
|
||||
return pbkdf2HashAlgorithm, nil
|
||||
default:
|
||||
return "", errors.Errorf("unsupported hash version (%d)", passwordHashVersion)
|
||||
}
|
||||
}
|
||||
|
||||
15
internal/user/password_hashings.go
Normal file
15
internal/user/password_hashings.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package user
|
||||
|
||||
import "github.com/pkg/errors"
|
||||
|
||||
// getPasswordHashAlgorithm returns the password hash algorithm given a version.
|
||||
func getPasswordHashAlgorithm(passwordHashVersion int) (string, error) {
|
||||
switch passwordHashVersion {
|
||||
case ScryptHashVersion:
|
||||
return scryptHashAlgorithm, nil
|
||||
case Pbkdf2HashVersion:
|
||||
return pbkdf2HashAlgorithm, nil
|
||||
default:
|
||||
return "", errors.Errorf("unsupported hash version (%d)", passwordHashVersion)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user