mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 06:40:54 +03:00
add bcrypt support
This commit is contained in:
committed by
drakkan
parent
88a288ccfe
commit
be9a1fb7c4
@@ -10,6 +10,8 @@ import (
|
||||
"golang.org/x/crypto/ssh"
|
||||
|
||||
"github.com/alexedwards/argon2id"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
"github.com/drakkan/sftpgo/logger"
|
||||
"github.com/drakkan/sftpgo/utils"
|
||||
)
|
||||
@@ -44,6 +46,15 @@ func sqlCommonValidateUserAndPass(username string, password string) (User, error
|
||||
logger.Warn(logSender, "error comparing password with argon hash: %v", err)
|
||||
return user, err
|
||||
}
|
||||
|
||||
} else if strings.HasPrefix(user.Password, bcryptPwdPrefix){
|
||||
err = bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(password))
|
||||
if err != nil {
|
||||
logger.Warn(logSender, "error comparing password with bcrypt hash: %v", err)
|
||||
return user, err
|
||||
}else{
|
||||
match = true
|
||||
}
|
||||
} else {
|
||||
// clear text password match
|
||||
match = (user.Password == password)
|
||||
|
||||
Reference in New Issue
Block a user