MCPcopy
hub / github.com/smallstep/cli / disco

Function disco

command/oauth/cmd.go:684–709  ·  view source on GitHub ↗
(provider string)

Source from the content-addressed store, hash-verified

682}
683
684func disco(provider string) (map[string]interface{}, error) {
685 u, err := url.Parse(provider)
686 if err != nil {
687 return nil, err
688 }
689 // TODO: OIDC and OAuth specify two different ways of constructing this
690 // URL. This is the OIDC way. Probably want to try both. See
691 // https://tools.ietf.org/html/rfc8414#section-5
692 if !strings.Contains(u.Path, "/.well-known/openid-configuration") {
693 u.Path = path.Join(u.Path, "/.well-known/openid-configuration")
694 }
695 resp, err := http.Get(u.String())
696 if err != nil {
697 return nil, errors.Wrapf(err, "error retrieving %s", u.String())
698 }
699 defer resp.Body.Close()
700 b, err := io.ReadAll(resp.Body)
701 if err != nil {
702 return nil, errors.Wrapf(err, "error retrieving %s", u.String())
703 }
704 details := make(map[string]interface{})
705 if err = json.Unmarshal(b, &details); err != nil {
706 return nil, errors.Wrapf(err, "error reading %s: unsupported format", u.String())
707 }
708 return details, err
709}
710
711// postForm simulates http.PostForm but adds the header "Accept:
712// application/json", without this header GitHub will use

Callers 1

newOauthFunction · 0.85

Calls 2

StringMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…