Add password hashing with argon2

This commit is contained in:
bronku 2025-03-28 21:53:04 +01:00
parent 01da46b81e
commit 1dd0332bc1
11 changed files with 107 additions and 15 deletions

View file

@ -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[:])
}