Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AlgorithmsCmd = &cobra.Command{ Use: "algorithms", Short: "list available algorithms", Long: "lists all the available algorithms you can use for signing the JWT", Run: func(cmd *cobra.Command, args []string) { for _, a := range model.Algorithms { fmt.Println(a) } }, }
AlgorithmsCmd lists the supported algorithms
View Source
var CreateCmd = &cobra.Command{ Use: "create [flags]", Short: "create a JWT", Long: "creates a JWT using the specified flags and key/value pairs", Run: func(cmd *cobra.Command, args []string) { algorithm, ok := model.AlgorithmForName(algo) if !ok { fmt.Printf("algorithm '%s' not valid\n", algo) os.Exit(1) } claims := &jwt.StandardClaims{ Subject: sub, } var signedString string var err error token := jwt.NewWithClaims(algorithm, claims) if algorithm == jwt.SigningMethodNone { signedString, err = token.SignedString(jwt.UnsafeAllowNoneSignatureType) } else { signedString, err = token.SignedString([]byte(key)) } if err != nil { fmt.Println(err.Error()) os.Exit(1) } fmt.Println(signedString) }, }
CreateCmd lists the supported algorithms
View Source
var RootCmd = &cobra.Command{
Use: "jwtbot",
Short: "A CLI for creating JWTs",
Long: "jwtbot lets you create JWTs",
}
RootCmd is the root command for jwtbot
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.