Skip to content

Commit

Permalink
removed unnecessary response code checks
Browse files Browse the repository at this point in the history
  • Loading branch information
someone1 committed Sep 21, 2018
1 parent f5f1bc8 commit 57304e1
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 22 deletions.
6 changes: 0 additions & 6 deletions iam_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/base64"
"fmt"
"net/http"

"github.com/dgrijalva/jwt-go"
"google.golang.org/api/iam/v1"
Expand Down Expand Up @@ -40,11 +39,6 @@ func signBlob(ctx context.Context, iamService *iam.Service, config *IAMConfig, s
return "", err
}

// Check the response
if signResp.HTTPStatusCode != http.StatusOK {
return "", fmt.Errorf("unexpected response code from signing request, expected %d but got %d instead", http.StatusOK, signResp.HTTPStatusCode)
}

config.lastKeyID = signResp.KeyId

signature, err := base64.StdEncoding.DecodeString(signResp.Signature)
Expand Down
6 changes: 0 additions & 6 deletions iam_jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package gcpjwt
import (
"context"
"fmt"
"net/http"
"strings"

"github.com/dgrijalva/jwt-go"
Expand Down Expand Up @@ -48,11 +47,6 @@ func signJwt(ctx context.Context, iamService *iam.Service, config *IAMConfig, si
return "", err
}

// Check the response
if signResp.HTTPStatusCode != http.StatusOK {
return "", fmt.Errorf("gcpjwt: expected response code `%d` from signing request, got `%d`", http.StatusOK, signResp.HTTPStatusCode)
}

config.lastKeyID = signResp.KeyId

return signResp.SignedJwt, nil
Expand Down
10 changes: 0 additions & 10 deletions kms.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"encoding/pem"
"fmt"
"math/big"
"net/http"

"github.com/dgrijalva/jwt-go"
"google.golang.org/api/cloudkms/v1"
Expand Down Expand Up @@ -181,10 +180,6 @@ func KMSVerfiyKeyfunc(ctx context.Context, config *KMSConfig) (jwt.Keyfunc, erro
return nil, err
}

if response.HTTPStatusCode != http.StatusOK {
return nil, fmt.Errorf("gcpjwt: expected response code `%d` from signing request, got `%d`", http.StatusOK, response.HTTPStatusCode)
}

keyBytes := []byte(response.Pem)
block, _ := pem.Decode(keyBytes)
if block == nil {
Expand Down Expand Up @@ -241,11 +236,6 @@ func signKMS(ctx context.Context, config *KMSConfig, request *cloudkms.Asymmetri
return "", err
}

// Check the response
if signResp.HTTPStatusCode != http.StatusOK {
return "", fmt.Errorf("gcpjwt: expected response code `%d` from signing request, got `%d`", http.StatusOK, signResp.HTTPStatusCode)
}

// Decode the response
decodedSignature, err := base64.StdEncoding.DecodeString(signResp.Signature)
if err != nil {
Expand Down

0 comments on commit 57304e1

Please sign in to comment.