add user agent
This commit is contained in:
parent
ce652e0590
commit
90b05bac5f
|
@ -12,6 +12,8 @@ func TestCachesKey(t *testing.T) {
|
||||||
testCachesKey(t, "https://bigsquid.auth0.com/")
|
testCachesKey(t, "https://bigsquid.auth0.com/")
|
||||||
clear()
|
clear()
|
||||||
testCachesKey(t, "https://bigsquid.auth0.com")
|
testCachesKey(t, "https://bigsquid.auth0.com")
|
||||||
|
clear()
|
||||||
|
testCachesKey(t, "https://big-squid.github.io/")
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCachesKey(t *testing.T, url string) {
|
func testCachesKey(t *testing.T, url string) {
|
||||||
|
|
|
@ -36,8 +36,9 @@ func OIDCJWKs(baseURL string) (map[string]map[string]string, map[string]keypairs
|
||||||
// WellKnownJWKs calls JWKs with baseURL + /.well-known/jwks.json as constructs the jwks_uri
|
// WellKnownJWKs calls JWKs with baseURL + /.well-known/jwks.json as constructs the jwks_uri
|
||||||
func WellKnownJWKs(baseURL string) (map[string]map[string]string, map[string]keypairs.PublicKey, error) {
|
func WellKnownJWKs(baseURL string) (map[string]map[string]string, map[string]keypairs.PublicKey, error) {
|
||||||
baseURL = normalizeBaseURL(baseURL)
|
baseURL = normalizeBaseURL(baseURL)
|
||||||
|
url := baseURL + ".well-known/jwks.json"
|
||||||
|
|
||||||
return JWKs(baseURL + ".well-known/jwks.json")
|
return JWKs(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// JWKs fetches and parses a jwks.json (assuming well-known format)
|
// JWKs fetches and parses a jwks.json (assuming well-known format)
|
||||||
|
@ -121,12 +122,15 @@ func safeFetch(url string, decoder decodeFunc) error {
|
||||||
}).Dial,
|
}).Dial,
|
||||||
TLSHandshakeTimeout: 5 * time.Second,
|
TLSHandshakeTimeout: 5 * time.Second,
|
||||||
}
|
}
|
||||||
var netClient = &http.Client{
|
var client = &http.Client{
|
||||||
Timeout: time.Second * 10,
|
Timeout: time.Second * 10,
|
||||||
Transport: netTransport,
|
Transport: netTransport,
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := netClient.Get(url)
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
|
req.Header.Set("User-Agent", "go-keypairs/keyfetch")
|
||||||
|
req.Header.Set("Accept", "application/json;q=0.9,*/*;q=0.8")
|
||||||
|
res, err := client.Do(req)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue