MCPcopy
hub / github.com/cloudfoundry/cli / Authenticate

Method Authenticate

cf/api/authentication/authentication.go:116–141  ·  view source on GitHub ↗
(credentials map[string]string)

Source from the content-addressed store, hash-verified

114}
115
116func (uaa UAARepository) Authenticate(credentials map[string]string) error {
117 data := url.Values{
118 "grant_type": {"password"},
119 "scope": {""},
120 }
121 for key, val := range credentials {
122 data[key] = []string{val}
123 }
124
125 err := uaa.getAuthToken(data)
126 if err != nil {
127 httpError, ok := err.(errors.HTTPError)
128 if ok {
129 switch {
130 case httpError.StatusCode() == http.StatusUnauthorized:
131 return errors.New(T("Credentials were rejected, please try again."))
132 case httpError.StatusCode() >= http.StatusInternalServerError:
133 return errors.New(T("The targeted API endpoint could not be reached."))
134 }
135 }
136
137 return err
138 }
139
140 return nil
141}
142
143func (uaa UAARepository) DumpRequest(req *http.Request) {
144 uaa.dumper.DumpRequest(req)

Callers

nothing calls this directly

Calls 3

getAuthTokenMethod · 0.95
NewFunction · 0.92
StatusCodeMethod · 0.65

Tested by

no test coverage detected