Skip to content

Commit

Permalink
Using the default http client for getting public keys (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiranya911 committed Jul 17, 2018
1 parent d6907ca commit 1d2a52c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
- [added] The Admin SDK can now read the Firebase/GCP project ID from
both `GCLOUD_PROJECT` and `GOOGLE_CLOUD_PROJECT` environment
variables.
- [fixed] Using the default, unauthorized HTTP client to retrieve
public keys when verifying ID tokens.

# v3.1.0

Expand Down
3 changes: 2 additions & 1 deletion auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"encoding/json"
"errors"
"fmt"
"net/http"
"strings"

"golang.org/x/net/context"
Expand Down Expand Up @@ -128,7 +129,7 @@ func NewClient(ctx context.Context, conf *internal.AuthConfig) (*Client, error)

return &Client{
is: is,
keySource: newHTTPKeySource(idTokenCertURL, hc),
keySource: newHTTPKeySource(idTokenCertURL, http.DefaultClient),
projectID: conf.ProjectID,
signer: signer,
version: "Go/Admin/" + conf.Version,
Expand Down
4 changes: 4 additions & 0 deletions auth/token_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"encoding/json"
"encoding/pem"
"errors"
"fmt"
"io/ioutil"
"net/http"
"strconv"
Expand Down Expand Up @@ -98,6 +99,9 @@ func (k *httpKeySource) refreshKeys(ctx context.Context) error {
if err != nil {
return err
}
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("invalid response (%d) while retrieving public keys: %s", resp.StatusCode, string(contents))
}
newKeys, err := parsePublicKeys(contents)
if err != nil {
return err
Expand Down

0 comments on commit 1d2a52c

Please sign in to comment.