MCPcopy Create free account
hub / github.com/crewjam/saml / FetchMetadata

Function FetchMetadata

samlsp/fetch_metadata.go:53–75  ·  view source on GitHub ↗

FetchMetadata returns metadata from an IDP metadata URL.

(ctx context.Context, httpClient *http.Client, metadataURL url.URL)

Source from the content-addressed store, hash-verified

51
52// FetchMetadata returns metadata from an IDP metadata URL.
53func FetchMetadata(ctx context.Context, httpClient *http.Client, metadataURL url.URL) (*saml.EntityDescriptor, error) {
54 req, err := http.NewRequest("GET", metadataURL.String(), nil)
55 if err != nil {
56 return nil, err
57 }
58 req = req.WithContext(ctx)
59
60 resp, err := httpClient.Do(req)
61 if err != nil {
62 return nil, err
63 }
64 defer resp.Body.Close()
65 if resp.StatusCode >= 400 {
66 return nil, httperr.Response(*resp)
67 }
68
69 data, err := ioutil.ReadAll(resp.Body)
70 if err != nil {
71 return nil, err
72 }
73
74 return ParseMetadata(data)
75}

Callers 6

mainFunction · 0.92
mainFunction · 0.92
TestFetchMetadataFunction · 0.85

Calls 3

ParseMetadataFunction · 0.85
StringMethod · 0.80
CloseMethod · 0.80

Tested by 4

TestFetchMetadataFunction · 0.68