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

Don't use a pointer to an interface #117

Merged
merged 1 commit into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions client-lib/go/client/jvs_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func NewJVSClient(ctx context.Context, config *JVSConfig) (*JVSClient, error) {
}

// ValidateJWT takes a jwt string, converts it to a JWT, and validates the signature.
func (j *JVSClient) ValidateJWT(jwtStr string) (*jwt.Token, error) {
func (j *JVSClient) ValidateJWT(jwtStr string) (jwt.Token, error) {
// Handle unsigned tokens.
if strings.HasSuffix(jwtStr, UnsignedPostfix) {
token, err := jwt.Parse([]byte(jwtStr), jwt.WithVerify(false))
Expand All @@ -74,7 +74,7 @@ func (j *JVSClient) ValidateJWT(jwtStr string) (*jwt.Token, error) {
if err := j.unsignedTokenValidAndAllowed(token); err != nil {
return nil, fmt.Errorf("token unsigned and could not be validated: %w", err)
}
return &token, nil
return token, nil
}
return jvscrypto.ValidateJWT(j.keys, jwtStr)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/jvscrypto/kmsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,13 @@ func getLabelValue(versionName string) (string, error) {
}

// ValidateJWT takes a jwt string, converts it to a JWT, and validates the signature.
func ValidateJWT(keySet jwk.Set, jwtStr string) (*jwt2.Token, error) {
func ValidateJWT(keySet jwk.Set, jwtStr string) (jwt2.Token, error) {
verifiedToken, err := jwt2.Parse([]byte(jwtStr), jwt2.WithKeySet(keySet, jws.WithInferAlgorithmFromKey(true)))
if err != nil {
return nil, fmt.Errorf("failed to verify jwt %s: %w", jwtStr, err)
}

return &verifiedToken, nil
return verifiedToken, nil
}

// JWKList creates a list of public keys in JWK format.
Expand Down
2 changes: 1 addition & 1 deletion test/integ/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func TestJVS(t *testing.T) {
return
}

tokenMap, err := (*token).AsMap(ctx)
tokenMap, err := token.AsMap(ctx)
if err != nil {
t.Errorf("Couldn't convert token to map: %v", err)
return
Expand Down