debug flag

This commit is contained in:
Dave Grijalva 2014-05-19 22:19:42 -07:00
parent e066f61666
commit 8724cca5ea
1 changed files with 7 additions and 0 deletions

View File

@ -22,6 +22,7 @@ var (
flagAlg = flag.String("alg", "", "signing algorithm identifier") flagAlg = flag.String("alg", "", "signing algorithm identifier")
flagKey = flag.String("key", "", "path to key file or '-' to read from stdin") flagKey = flag.String("key", "", "path to key file or '-' to read from stdin")
flagPretty = flag.Bool("pretty", true, "output pretty JSON") flagPretty = flag.Bool("pretty", true, "output pretty JSON")
flagDebug = flag.Bool("debug", false, "print out all kinds of debug data")
// Modes - exactly one of these is required // Modes - exactly one of these is required
flagSign = flag.String("sign", "", "path to claims object to sign or '-' to read from stdin") flagSign = flag.String("sign", "", "path to claims object to sign or '-' to read from stdin")
@ -94,6 +95,12 @@ func verifyToken() error {
return loadData(*flagKey) return loadData(*flagKey)
}) })
// Print some debug data
if *flagDebug && token != nil {
fmt.Printf("Header:\n%v\n", token.Header)
fmt.Printf("Claims:\n%v\n", token.Claims)
}
// Print an error if we can't parse for some reason // Print an error if we can't parse for some reason
if err != nil { if err != nil {
return fmt.Errorf("Couldn't parse token: %v", err) return fmt.Errorf("Couldn't parse token: %v", err)