Configuring a Google identity provider

    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.

    Using Google as an identity provider allows any Google user to authenticate to your server. You can limit authentication to members of a specific hosted domain with the hostedDomain configuration attribute.

    Using Google as an identity provider requires users to get a token using <namespace_route>/oauth/token/request to use with command-line tools.

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

    Procedure

    • Create a Secret object containing a string by using the following command:

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

    Google CR

    1. apiVersion: config.openshift.io/v1
    2. kind: OAuth
    3. metadata:
    4. name: cluster
    5. spec:
    6. identityProviders:
    7. - name: googleidp (1)
    8. mappingMethod: claim (2)
    9. type: Google
    10. clientSecret: (4)
    11. name: google-secret
    12. hostedDomain: "example.com" (5)
    1This provider name is prefixed to the Google numeric user ID to form an identity name. It is also used to build the redirect URL.
    2Controls how mappings are established between this provider’s identities and User objects.
    3The client ID of a registered Google project. The project must be configured with a redirect URI of ;.
    4Reference to an OKD Secret object containing the client secret issued by Google.
    5A hosted domain used to restrict sign-in accounts. Optional if the lookup mappingMethod is used. If empty, any Google account is allowed to authenticate.

    Additional resources

    • See for information on parameters, such as mappingMethod, that are common to all identity providers.

    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.

    1. Apply the defined CR:

    2. Obtain a token from the OAuth server.

      As long as the kubeadmin user has been removed, the command provides instructions on how to access a web page where you can retrieve the token.

      You can also access this page from the web console by navigating to (?) HelpCommand Line ToolsCopy Login Command.

    3. Log in to the cluster, passing in the token to authenticate.

      1. $ oc login --token=<token>

      This identity provider does not support logging in with a user name and password.

    4. Confirm that the user logged in successfully, and display the user name.