Skip to content

Commit

Permalink
Fix jwt -show
Browse files Browse the repository at this point in the history
Some time ago (was lazy to dig history) jwt.Parse was changed to require
non-nil keyFunc.

This broke `jwt -show` command that prints header and claims and
does not validate the token:
```
$ echo $TOKEN | jwt -show -
Error: malformed token: token is unverifiable: no keyfunc was provided
```

This change fixes `jwt -show`.
  • Loading branch information
AlexanderYastrebov committed Aug 28, 2024
1 parent f961c72 commit be259da
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/jwt/main.go
Original file line number Diff line number Diff line change
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

0 comments on commit be259da

Please # to comment.