Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix jwt -show #406

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cmd/jwt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ var (
flagHead = make(ArgList)

// Modes - exactly one of these is required
flagSign = flag.String("sign", "", "path to claims object to sign, '-' to read from stdin, or '+' to use only -claim args")
flagVerify = flag.String("verify", "", "path to JWT token to verify or '-' to read from stdin")
flagShow = flag.String("show", "", "path to JWT file or '-' to read from stdin")
flagSign = flag.String("sign", "", "path to claims file to sign, '-' to read from stdin, or '+' to use only -claim args")
flagVerify = flag.String("verify", "", "path to JWT token file to verify or '-' to read from stdin")
flagShow = flag.String("show", "", "path to JWT token file to show without verification or '-' to read from stdin")
)

func main() {
Expand All @@ -43,7 +43,7 @@ func main() {
// Usage message if you ask for -help or if you mess up inputs.
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
fmt.Fprintf(os.Stderr, " One of the following flags is required: sign, verify\n")
fmt.Fprintf(os.Stderr, " One of the following flags is required: sign, verify or show\n")
flag.PrintDefaults()
}

Expand All @@ -69,7 +69,7 @@ func start() error {
return showToken()
default:
flag.Usage()
return fmt.Errorf("none of the required flags are present. What do you want me to do?")
return fmt.Errorf("none of the required flags are present. What do you want me to do?")
}
}

Expand Down Expand Up @@ -273,7 +273,7 @@ func showToken() error {
fmt.Fprintf(os.Stderr, "Token len: %v bytes\n", len(tokData))
}

token, err := jwt.Parse(string(tokData), nil)
token, _, err := jwt.NewParser().ParseUnverified(string(tokData), make(jwt.MapClaims))
if err != nil {
return fmt.Errorf("malformed token: %w", err)
}
Expand Down
Loading