- Clarified web handler name

- Implemented Configuration Loader with unauthorized error handling
- More elaborate test user config
- Use Viper Unmarshalling for User Config loading
- Centralized password hasing code
This commit is contained in:
2021-08-22 14:36:55 +02:00
parent 9f1b9f1690
commit 9a31bbc912
4 changed files with 98 additions and 17 deletions

View File

@ -9,7 +9,6 @@ import (
"gitea.nehmer.net/torben/dyndns/service"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"golang.org/x/crypto/bcrypt"
"golang.org/x/crypto/ssh/terminal"
)
@ -36,7 +35,7 @@ have to store a plaintext password.`,
log.Fatalln("the passwords do not match.")
}
hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
hash, err := service.HashPassword(password)
if err != nil {
log.Fatalf("failed to create password hash: %v", err)
}