Configuring a Keystone identity provider

Configure the keystone identity provider to integrate your OKD cluster with Keystone to enable shared authentication with an OpenStack Keystone v3 server configured to store users in an internal database. This configuration allows users to log in to OKD with their Keystone credentials.

Keystone is an OpenStack project that provides identity, token, catalog, and policy services.

You can configure the integration with Keystone so that the new OKD users are based on either the Keystone user names or unique Keystone IDs. With both methods, users log in by entering their Keystone user name and password. Basing the OKD users off of the Keystone ID is more secure. If you delete a Keystone user and create a new Keystone user with that user name, the new user might have access to the old user’s resources.

About identity providers in OKD

By default, only a kubeadmin user exists on your cluster. To specify an identity provider, you must create a custom resource (CR) that describes that identity provider and add it to the cluster.

OKD user names containing /, :, and % are not supported.

Creating the secret

Identity providers use OKD Secret objects in the openshift-config namespace to contain the client secret, client certificates, and keys.

  • You can define an OKD Secret object containing a string by using the following command.

    1. $ oc create secret generic <secret_name> --from-literal=clientSecret=<secret> -n openshift-config
  • You can define an OKD Secret object containing the contents of a file, such as a certificate file, by using the following command.

    1. $ oc create secret generic <secret_name> --from-file=/path/to/file -n openshift-config

Creating a config map

Identity providers use OKD ConfigMap objects in the openshift-config namespace to contain the certificate authority bundle. These are primarily used to contain certificate bundles needed by the identity provider.

Procedure

  • Define an OKD ConfigMap object containing the certificate authority by using the following command. The certificate authority must be stored in the ca.crt key of the ConfigMap object.

    1. $ oc create configmap ca-config-map --from-file=ca.crt=/path/to/ca -n openshift-config

Sample Keystone CR

The following custom resource (CR) shows the parameters and acceptable values for a Keystone identity provider.

Keystone CR

  1. apiVersion: config.openshift.io/v1
  2. kind: OAuth
  3. metadata:
  4. name: cluster
  5. spec:
  6. identityProviders:
  7. - name: keystoneidp (1)
  8. mappingMethod: claim (2)
  9. type: Keystone
  10. keystone:
  11. domainName: default (3)
  12. url: https://keystone.example.com:5000 (4)
  13. ca: (5)
  14. name: ca-config-map
  15. tlsClientCert: (6)
  16. name: client-cert-secret
  17. tlsClientKey: (7)
  18. name: client-key-secret
1This provider name is prefixed to provider user names to form an identity name.
2Controls how mappings are established between this provider’s identities and User objects.
3Keystone domain name. In Keystone, usernames are domain-specific. Only a single domain is supported.
4The URL to use to connect to the Keystone server (required). This must use https.
5Optional: Reference to an OKD ConfigMap object containing the PEM-encoded certificate authority bundle to use in validating server certificates for the configured URL.
6Optional: Reference to an OKD Secret object containing the client certificate to present when making requests to the configured URL.
7Reference to an OKD Secret object containing the key for the client certificate. Required if tlsClientCert is specified.

Additional resources

Adding an identity provider to your clusters

After you install your cluster, add an identity provider to it so your users can authenticate.

Prerequisites

  • Create an OKD cluster.

  • Create the custom resource (CR) for your identity providers.

  • You must be logged in as an administrator.

Procedure

  1. Apply the defined CR:

    1. $ oc apply -f </path/to/CR>

    If a CR does not exist, oc apply creates a new CR and might trigger the following warning: Warning: oc apply should be used on resources created by either oc create —save-config or oc apply. In this case you can safely ignore this warning.

  2. Log in to the cluster as a user from your identity provider, entering the password when prompted.

    1. $ oc login -u <username>
  3. Confirm that the user logged in successfully, and display the user name.

    1. $ oc whoami