Add -passwordHash support (#42)

* Update main.go

* Update main.go

* Set

* Set password to db

* Main

- Password hash, after trimming, cannot be empty

* Backend

- Assume incoming data is already a hash

* Main

- CLeaned up

* README

- Updated command-line argument documentation

* Menton this

* lower case

* SQLITE Driver

- Removed comments

* Main

- `passwordhash` only valiud when non-""

* Main

- Try running `Cost([]byte)` on the UTF-8 bytes to verify the hash
This commit is contained in:
Tristan B. Velloza Kildaire
2025-12-01 22:43:35 +02:00
committed by GitHub
parent 59426fabf1
commit 12c153a364
3 changed files with 34 additions and 7 deletions

View File

@@ -74,12 +74,8 @@ func (t *TableConfig) ConfigSet(key, value string) error {
})
}
func (t *TableConfig) ConfigSetPassword(password string) error {
hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
if err != nil {
return fmt.Errorf("bcrypt.GenerateFromPassword: %w", err)
}
return t.ConfigSet("password", string(hash))
func (t *TableConfig) ConfigSetPassword(passwordHash string) error {
return t.ConfigSet("password", passwordHash)
}
func (t *TableConfig) ConfigTryPassword(password string) (bool, error) {