Single Sign-On (SSO) enables Cloud Foundry (CF) users to authenticate with third-party service dashboards using their CF credentials. Service dashboards are web interfaces which enable users to interact with some or all of the features the service offers. SSO provides a streamlined experience for users, limiting repeated logins and multiple accounts across their managed services. The user’s credentials are never directly transmitted to the service since the OAuth protocol handles authentication.
Dashboard SSO was introduced in cf-release v169 so this or a newer version is required to support the feature.
Enabling the SSO Feature
To enable the SSO feature, the Cloud Controller requires a UAA client with sufficient permissions to create and delete clients for the service brokers that request them. This client can be configured by including the following snippet in the cf-release manifest:
When this client is not present in the cf-release manifest, Cloud Controller cannot manage UAA clients and an operator will receive a warning when creating or updating service brokers that advertise the
dashboard_client properties discussed below.
Service Broker Responsibilities
Registering the Dashboard Client
A service broker must include the
dashboard_client field in the JSON response from its catalog endpoint for each service implementing this feature. A valid response would appear as follows:
dashboard_client field is a hash containing three fields:
id is the unique identifier for the OAuth client that will be created for your service dashboard on the token server (UAA), and will be used by your dashboard to authenticate with the token server (UAA). If the client id is already taken, CF will return an error when registering or updating the broker.
secret is the shared secret your dashboard will use to authenticate with the token server (UAA).
redirect_uri is used by the token server as an additional security precaution. UAA will not provide a token if the callback URL declared by the service dashboard doesn’t match the domain name in
redirect_uri. The token server matches on the domain name, so any paths will also match; e.g. a service dashboard requesting a token and declaring a callback URL of
http://p-mysql.example.com/manage/auth would be approved if
redirect_uri for its client is
When a service broker which advertises the
dashboard_client property for any of its services is added or updated, Cloud Controller will create or update UAA clients as necessary. This client will be used by the service dashboard to authenticate users.
A service broker should return a URL for the
dashboard_url field in response to a provision request. Cloud Controller clients should expose this URL to users.
dashboard_url can be found in the response from Cloud Controller to create a service instance, enumerate service instances, space summary, and other endpoints.
Users can then navigate to the service dashboard at the URL provided by
dashboard_url, initiating the OAuth login flow.
Service Dashboard Responsibilities
When a user navigates to the URL from
dashboard_url, the service dashboard should initiate the OAuth login flow. A summary of the flow can be found in section 1.2 of the OAuth RFC. OAuth expects the presence of an Authorization Endpoint and a Token Endpoint. In CF these endpoints are provided by the UAA. Clients can discover the location of UAA from Cloud Controller’s info endpoint; in the response the location can be found in the
$ curl api.example.com/info
":2,"description":"Cloud Foundry sponsored by Example Company","authorization_endpoint":
To enable service dashboards to support SSO for service instances created from different CF instances, the /v2/info url is sent to service brokers in the
X-Api-Info-Location header of every API call. A service dashboard should be able to discover this URL from the broker, and enabling the dashboard to contact the appropriate UAA for a particular service instance.
A service dashboard should implement the OAuth Authorization Code Grant type (UAA documentation, RFC documentation).
When a user visits the service dashboard at the value of
dashboard_url, the dashboard should redirect the user’s browser to the Authorization Endpoint and include its
redirect_uri (callback URL with domain matching the value of
dashboard_client.redirect_uri), and list of requested scopes.
Scopes are permissions included in the token a dashboard client will receive from UAA, and which Cloud Controller uses to enforce access. A client should request the minimum scopes it requires. The minimum scopes required for this workflow are
openid. For an explanation of the scopes available to dashboard clients, see On Scopes.
UAA authenticates the user by redirecting the user to the Login Server, where the user then approves or denies the scopes requested by the service dashboard. The user is presented with human readable descriptions for permissions representing each scope. After authentication, the user’s browser is redirected back to the Authorization endpoint on UAA with an authentication cookie for the UAA.
Assuming the user grants access, UAA redirects the user’s browser back to the value of
redirect_uri the dashboard provided in its request to the Authorization Endpoint. The
Location header in the response includes an authorization code.
HTTP/1.1 302 Found
The dashboard UI should then request an access token from the Token Endpoint by including the authorization code received in the previous step. When making the request the dashboard must authenticate with UAA by passing the client
secret in a basic auth header. UAA will verify that the client id matches the client it issued the code to. The dashboard should also include the
redirect_uri used to obtain the authorization code for verification.
UAA authenticates the dashboard client, validates the authorization code, and ensures that the redirect URI received matches the URI used to redirect the client when the authorization code was issues. If valid, UAA responds back with an access token and a refresh token.
Checking User Permissions
UAA is responsible for authenticating a user and providing the service with an access token with the requested permissions. However, after the user has been logged in, it is the responsibility of the service dashboard to verify that the user making the request to manage an instance currently has access to that service instance.
The service can accomplish this with a GET to the
/v2/service_instances/:guid/permissions endpoint on the Cloud Controller. The request must include a token for an authenticated user and the service instance guid. The token is the same one obtained from the UAA in response to a request to the Token Endpoint, described above.
curl -H 'Content-Type: application/json' \
-H 'Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoid' \
The response includes the following fields which indicate the various user permissions for the given service instance:
manage – a
true value indicates that the user has sufficient permissions to make changes to and update the service instance;
false indicates insufficient permissions.
read – a
true value indicates that the user has permission to access read-only diagnostic and monitoring information for the given service instance (e.g. permission to view a read-only dashboard);
false indicates insufficient permissions.
Since administrators may change the permissions of users at any time, the service should check this endpoint whenever a user uses the SSO flow to access the service’s UI.
Scopes let you specify exactly what type of access you need. Scopes limit access for OAuth tokens. They do not grant any additional permission beyond that which the user already has.
The following two scopes are necessary to implement the integration. Most dashboard shouldn’t need more permissions than these scopes enabled.
|Allows access to basic data about the user, such as email addresses
|Allows access to the CC endpoint that specifies whether the user can manage a given service instance
Dashboards with extended capabilities may need to request these additional scopes:
|Allows read access to all resources the user is authorized to read
|Allows write access to all resources the user is authorized to update / create / delete
The MySQL Service Broker is an example of a broker that also implements a SSO dashboard. The login flow is implemented using the OmniAuth library and a custom UAA OmniAuth Strategy. See this OmniAuth wiki page for instructions on how to create your own strategy.
The UAA OmniAuth strategy is used to first get an authorization code, as documented in this section of the UAA documentation. The user is redirected back to the service (as specified by the
callback_path option or the default
auth/cloudfoundry/callback path) with the authorization code. Before the application / action is dispatched, the OmniAuth strategy uses the authorization code to get a token and uses the token to request information from UAA to fill the
omniauth.auth environment variable. When OmniAuth returns control to the application, the
omniauth.auth environment variable hash will be filled with the token and user information obtained from UAA as seen in the Auth Controller.
- UAA clients are scoped to services. There must be a
dashboard_client entry for each service that uses SSO integration.
dashboard_client id must be unique across the CF deployment.
Create a pull request or raise an issue on the source for this page in GitHub