Add password hashing with argon2
This commit is contained in:
parent
01da46b81e
commit
1dd0332bc1
11 changed files with 107 additions and 15 deletions
|
|
@ -1,10 +1,18 @@
|
|||
package auth
|
||||
|
||||
import "errors"
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/Bronku/iroon/internal/crypto"
|
||||
)
|
||||
|
||||
func (a *Authenticator) verifyCredentials(login, password string) error {
|
||||
|
||||
if login == "admin" && password == "secret" {
|
||||
user, ok := a.s.GetUser(login)
|
||||
if !ok {
|
||||
return errors.New("user with this login doesn't exist")
|
||||
}
|
||||
hash := crypto.PasswordHash(password, user.Salt)
|
||||
if hash == user.Password {
|
||||
return nil
|
||||
}
|
||||
return errors.New("wrong credentials")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue