summaryrefslogtreecommitdiff
path: root/pkg/model/account.go
diff options
context:
space:
mode:
authorJulien Dessaux2024-11-17 00:05:22 +0100
committerJulien Dessaux2024-12-17 23:19:18 +0100
commit25ed1188ed970a19675befef12afe68045565c4a (patch)
tree5cfc55047d833400028fb69a7f069f5cedecaacd /pkg/model/account.go
parentfix(tfstated): hash passwords instead of relying on the database encryption key (diff)
downloadtfstated-25ed1188ed970a19675befef12afe68045565c4a.tar.gz
tfstated-25ed1188ed970a19675befef12afe68045565c4a.tar.bz2
tfstated-25ed1188ed970a19675befef12afe68045565c4a.zip
chore(tfstated): refactor helpers to their own package
Diffstat (limited to 'pkg/model/account.go')
-rw-r--r--pkg/model/account.go19
1 files changed, 2 insertions, 17 deletions
diff --git a/pkg/model/account.go b/pkg/model/account.go
index 4336dfa..7a69685 100644
--- a/pkg/model/account.go
+++ b/pkg/model/account.go
@@ -1,17 +1,10 @@
package model
import (
- "crypto/sha256"
"crypto/subtle"
"time"
- "git.adyxax.org/adyxax/tfstated/pkg/scrypto"
- "golang.org/x/crypto/pbkdf2"
-)
-
-const (
- PBKDF2Iterations = 600000
- SaltSize = 32
+ "git.adyxax.org/adyxax/tfstated/pkg/helpers"
)
type AccountContextKey struct{}
@@ -28,14 +21,6 @@ type Account struct {
}
func (account *Account) CheckPassword(password string) bool {
- hash := HashPassword(password, account.Salt)
+ hash := helpers.HashPassword(password, account.Salt)
return subtle.ConstantTimeCompare(hash, account.PasswordHash) == 1
}
-
-func GenerateSalt() []byte {
- return scrypto.RandomBytes(SaltSize)
-}
-
-func HashPassword(password string, salt []byte) []byte {
- return pbkdf2.Key([]byte(password), salt, PBKDF2Iterations, 32, sha256.New)
-}