cloudfoundry-attic / cf-dotnet-sdk

Cloud Foundry .NET SDK
Other
18 stars 13 forks source link

Login doesn't work when targeting IBM bluemix #62

Closed viovanov closed 9 years ago

viovanov commented 9 years ago

The /info endpoint of the Cloud Controller exposes two URLs for authentication:

  1. AuthorizationEndpoint - this should point to your login page (html web page, configurable by the administrator) but defaults to your UAA URL if you don't set it.
  2. TokenEndpoint - this is your UAA URL Code for these two is here: https://github.com/cloudfoundry/cloud_controller_ng/blob/a9b4920f61f045d0b6a14f5eb9b75443e1472abc/app/controllers/runtime/info_controller.rb#L14

The login problem when targeting bluemix is that the token endpoint does not behave as other token endpoints from other deployments. I tested with the AuthorizationUrl endpoint and it works. The reason this always works with the cf CLI is that the CLI uses the AuthorizationEndpoint to retrieve the token and makes an assumption (undocumented as far as I can tell) that if you use an "accept" "application/json" header, the server will respond like a token endpoint, and not reply with HTML. See here: https://github.com/cloudfoundry/cli/blob/428bd9d8a76ca6199b67560500b3e5b495cba2db/cf/api/authentication/authentication.go#L118 and here: https://github.com/cloudfoundry/cli/blob/d32d02159a6994163abf27349e0a98bb4dcaaa68/cf/net/gateway.go#L197

We need to implement the SDK like cf is implemented, which means we need to hook into Thinktecture to always send "accept: application/json" (so that UAA replies correctly).