Add password hashing with argon2
This commit is contained in:
parent
01da46b81e
commit
1dd0332bc1
11 changed files with 107 additions and 15 deletions
|
|
@ -1,17 +1,15 @@
|
|||
package auth
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/Bronku/iroon/internal/crypto"
|
||||
"github.com/Bronku/iroon/internal/models"
|
||||
)
|
||||
|
||||
func (a *Authenticator) newSession(user string) (http.Cookie, error) {
|
||||
key := generateKey()
|
||||
key := crypto.GenerateKey()
|
||||
var session models.Token
|
||||
var cookie http.Cookie
|
||||
session.User = user
|
||||
|
|
@ -30,11 +28,3 @@ func (a *Authenticator) newSession(user string) (http.Cookie, error) {
|
|||
//cookie.Secure = true
|
||||
return cookie, nil
|
||||
}
|
||||
|
||||
func generateKey() string {
|
||||
key := [32]byte{}
|
||||
if _, err := rand.Read(key[:]); err != nil {
|
||||
log.Fatal("can't generate a vaild key", err)
|
||||
}
|
||||
return base64.StdEncoding.EncodeToString(key[:])
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue