diff options
Diffstat (limited to 'cmd/cli/main.go')
-rw-r--r-- | cmd/cli/main.go | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/cmd/cli/main.go b/cmd/cli/main.go deleted file mode 100644 index 5cfd5e0..0000000 --- a/cmd/cli/main.go +++ /dev/null @@ -1,59 +0,0 @@ -package main - -import ( - "fmt" - "log" - "os" - "time" - - "github.com/lestrrat-go/jwx/v2/jwa" - "github.com/lestrrat-go/jwx/v2/jwt" - "github.com/urfave/cli/v2" - "go.neonxp.dev/djson/internal/config" -) - -func main() { - app := &cli.App{ - Name: "djson cli tool", - Commands: []*cli.Command{ - { - Name: "token", - Action: func(ctx *cli.Context) error { - cfg, err := config.Parse(ctx.String("config")) - if err != nil { - return err - } - - t := jwt.New() - t.Set(jwt.SubjectKey, `djson`) - t.Set(jwt.IssuedAtKey, time.Now()) - t.Set("allowed", []string{ - "a/b/c", - "d/e/f", - }) - signed, err := jwt.Sign(t, jwt.WithKey( - jwa.KeyAlgorithmFrom(cfg.JWT.Algorithm), - cfg.JWT.PrivateKey, - )) - if err != nil { - return err - } - fmt.Println(string(signed)) - return nil - }, - }, - }, - Action: cli.ShowAppHelp, - Flags: []cli.Flag{ - &cli.StringFlag{ - Name: "config", - Usage: "Path to config file", - Value: "/etc/djson/config.json", - }, - }, - } - - if err := app.Run(os.Args); err != nil { - log.Fatal(err) - } -} |