Files
job-search/internal/cli/config/command.go
T
bwilliams eba6af680f Added config generate-csrf-key, to store a CSRF key that survives restarts and works across instances
Without server.csrf.tokens.key, each server process signs CSRF tokens with
a random key of its own, so tokens are lost on a restart and rejected by
other instances. "job-search config generate-csrf-key" stores a new random
32-byte hex key in the configuration file, without printing it. --print
only prints a key, for JOBSEARCH_SERVER_CSRF_TOKENS_KEY or another
instance. An existing key is only replaced with --force, as that
invalidates every issued token, and no key is stored while
JOBSEARCH_SERVER_CSRF_TOKENS_KEY is set, as it would override the file.
2026-10-16 10:53:13 +01:00

32 lines
796 B
Go

package config
import (
"log/slog"
"github.com/spf13/cobra"
"git.avsdev.uk/Go/job-search/internal/cli"
)
// NewCommand returns the "config" command, which shows and edits the
// configuration.
func NewCommand(opts *cli.Options) *cobra.Command {
cmd := &cobra.Command{
Use: "config",
Short: "Configuration management",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
slog.Debug("command persistent pre-run", "command", "config")
},
PersistentPostRun: func(cmd *cobra.Command, args []string) {
slog.Debug("command persistent post-run", "command", "config")
},
}
cmd.AddCommand(commandShow(opts))
cmd.AddCommand(commandGet(opts))
cmd.AddCommand(commandSet(opts))
cmd.AddCommand(commandInit())
cmd.AddCommand(commandGenerateCSRFKey(opts))
return cmd
}