diff --git a/web/auth/lib_password.go b/web/auth/lib_password.go index 74a8af2..fab702f 100644 --- a/web/auth/lib_password.go +++ b/web/auth/lib_password.go @@ -4,9 +4,11 @@ import ( "golang.org/x/crypto/bcrypt" ) +var PasswordHashCost = bcrypt.DefaultCost + // HashPassword - create new hash of password func HashPassword(password string) (string, error) { - p, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) + p, err := bcrypt.GenerateFromPassword([]byte(password), PasswordHashCost) if err != nil { return "", err } diff --git a/web/auth/models_test.go b/web/auth/models_test.go index 04ae4ac..167d5fb 100644 --- a/web/auth/models_test.go +++ b/web/auth/models_test.go @@ -5,6 +5,7 @@ import ( gormigrate "github.com/genofire/gormigrate/v2" "github.com/google/uuid" + "golang.org/x/crypto/bcrypt" "gorm.io/gorm" "dev.sum7.eu/genofire/golang-lib/database" @@ -30,6 +31,7 @@ func SetupMigration(db *database.Database) { { ID: "10-data-0008-01-user", Migrate: func(tx *gorm.DB) error { + PasswordHashCost = bcrypt.MinCost user, err := NewUser("admin", "CHANGEME") if err != nil { return err