mirror of
https://github.com/decke/smtprelay.git
synced 2025-12-25 15:52:29 -07:00
Authentication checker converted to store passwords as bcrypt hashes
This commit is contained in:
7
main.go
7
main.go
@@ -16,6 +16,7 @@ import (
|
||||
|
||||
"github.com/chrj/smtpd"
|
||||
"github.com/vharitonsky/iniflags"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -113,8 +114,10 @@ func authChecker(peer smtpd.Peer, username string, password string) error {
|
||||
continue
|
||||
}
|
||||
|
||||
if username == parts[0] && password == parts[1] {
|
||||
return nil
|
||||
if username == parts[0] {
|
||||
if bcrypt.CompareHashAndPassword([]byte(parts[1]), []byte(password)) == nil {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user