diff --git a/connector/cloudfoundry/cloudfoundry.go b/connector/cloudfoundry/cloudfoundry.go index acfb77fd..32ec6a91 100644 --- a/connector/cloudfoundry/cloudfoundry.go +++ b/connector/cloudfoundry/cloudfoundry.go @@ -94,7 +94,7 @@ func (c *Config) Open(id string, logger log.Logger) (connector.Connector, error) } apiURL := strings.TrimRight(c.APIURL, "/") - apiResp, err := cloudfoundryConn.httpClient.Get(fmt.Sprintf("%s/v3/info", apiURL)) + apiResp, err := cloudfoundryConn.httpClient.Get(apiURL) if err != nil { logger.Errorf("failed-to-send-request-to-cloud-controller-api", err) return nil, err @@ -108,10 +108,17 @@ func (c *Config) Open(id string, logger log.Logger) (connector.Connector, error) return nil, err } - var apiResult map[string]interface{} + var apiResult struct { + Links struct { + Login struct { + Href string `json:"href"` + } `json:"login"` + } `json:"links"` + } + json.NewDecoder(apiResp.Body).Decode(&apiResult) - uaaURL := strings.TrimRight(apiResult["authorization_endpoint"].(string), "/") + uaaURL := strings.TrimRight(apiResult.Links.Login.Href, "/") uaaResp, err := cloudfoundryConn.httpClient.Get(fmt.Sprintf("%s/.well-known/openid-configuration", uaaURL)) if err != nil { logger.Errorf("failed-to-send-request-to-uaa-api", err) diff --git a/connector/cloudfoundry/cloudfoundry_test.go b/connector/cloudfoundry/cloudfoundry_test.go index b7c2e0ba..e90f66a7 100644 --- a/connector/cloudfoundry/cloudfoundry_test.go +++ b/connector/cloudfoundry/cloudfoundry_test.go @@ -165,11 +165,15 @@ func testSetup() *httptest.Server { }) }) - mux.HandleFunc("/v3/info", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { url := fmt.Sprintf("http://%s", r.Host) - json.NewEncoder(w).Encode(map[string]string{ - "authorization_endpoint": url, + json.NewEncoder(w).Encode(map[string]interface{}{ + "links": map[string]interface{}{ + "login": map[string]string{ + "href": url, + }, + }, }) })