From be259da476fd3fb2e249062324915a4f12798fa5 Mon Sep 17 00:00:00 2001 From: Alexander Yastrebov Date: Wed, 28 Aug 2024 20:20:48 +0200 Subject: [PATCH] Fix jwt -show 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`. --- cmd/jwt/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/jwt/main.go b/cmd/jwt/main.go index 37b4fccf..33c198ba 100644 --- a/cmd/jwt/main.go +++ b/cmd/jwt/main.go @@ -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) }