Compare commits

...

3 Commits

Author SHA1 Message Date
Stavros
143b13af2c refactor: remove short flags 2025-01-22 21:50:01 +02:00
Stavros
4457d6f525 feat: add cookie secure option in the cli 2025-01-22 21:37:59 +02:00
Stavros
b901744e03 fix: use password hash instead of password when verifying 2025-01-22 20:18:03 +02:00
3 changed files with 8 additions and 6 deletions

View File

@@ -100,17 +100,19 @@ func HandleError(err error, msg string) {
func init() {
rootCmd.AddCommand(cmd.UserCmd())
viper.AutomaticEnv()
rootCmd.Flags().IntP("port", "p", 3000, "Port to run the server on.")
rootCmd.Flags().Int("port", 3000, "Port to run the server on.")
rootCmd.Flags().String("address", "0.0.0.0", "Address to bind the server to.")
rootCmd.Flags().String("secret", "", "Secret to use for the cookie.")
rootCmd.Flags().String("app-url", "", "The tinyauth URL.")
rootCmd.Flags().String("users", "", "Comma separated list of users in the format username:bcrypt-hashed-password.")
rootCmd.Flags().String("users-file", "", "Path to a file containing users in the format username:bcrypt-hashed-password.")
rootCmd.Flags().Bool("cookie-secure", false, "Send cookie over secure connection only.")
viper.BindEnv("port", "PORT")
viper.BindEnv("address", "ADDRESS")
viper.BindEnv("secret", "SECRET")
viper.BindEnv("app-url", "APP_URL")
viper.BindEnv("users", "USERS")
viper.BindEnv("users-file", "USERS_FILE")
viper.BindEnv("cookie-secure", "COOKIE_SECURE")
viper.BindPFlags(rootCmd.Flags())
}

View File

@@ -76,8 +76,8 @@ var CreateCmd = &cobra.Command{
}
func init() {
CreateCmd.Flags().BoolVarP(&interactive, "interactive", "i", false, "Create a user interactively")
CreateCmd.Flags().BoolVarP(&docker, "docker", "d", false, "Format output for docker")
CreateCmd.Flags().StringVarP(&username, "username", "u", "", "Username")
CreateCmd.Flags().StringVarP(&password, "password", "p", "", "Password")
CreateCmd.Flags().BoolVar(&interactive, "interactive", false, "Create a user interactively")
CreateCmd.Flags().BoolVar(&docker, "docker", false, "Format output for docker")
CreateCmd.Flags().StringVar(&username, "username", "", "Username")
CreateCmd.Flags().StringVar(&password, "password", "", "Password")
}

View File

@@ -73,7 +73,7 @@ var VerifyCmd = &cobra.Command{
}
if docker {
userSplit[1] = strings.ReplaceAll(password, "$$", "$")
userSplit[1] = strings.ReplaceAll(userSplit[1], "$$", "$")
}
verifyErr := bcrypt.CompareHashAndPassword([]byte(userSplit[1]), []byte(password))