This is a cache of https://docs.okd.io/latest/authentication/identity_providers/configuring-github-identity-provider.html. It is a snapshot of the page at 2026-08-15T18:29:00.035+0000.
Configuring a GitHub or GitHub Enterprise identity provider - Configuring identity providers | Authentication and authorization | OKD 4
×

Configure the github identity provider so users can log in to OKD with GitHub or GitHub Enterprise accounts through OAuth. Use this integration when you want cluster users to authenticate with existing GitHub credentials instead of managing separate cluster passwords.

You can use the GitHub integration to connect to either GitHub or GitHub Enterprise. For GitHub Enterprise integrations, you must provide the hostname of your instance and can optionally provide a ca certificate bundle to use in requests to the server.

The following steps apply to both GitHub and GitHub Enterprise unless noted.

Identity providers in OKD

You can configure identity providers by creating a custom resource (CR) that describes the provider and adding it to the cluster. Identity providers enable user authentication in OKD beyond the default kubeadmin user.

OKD usernames containing /, :, and % are not supported.

About GitHub authentication

Configure GitHub authentication so users can log in with GitHub or GitHub Enterprise credentials. Separate OKD user accounts are not required.

To prevent anyone with any GitHub user ID from logging in to your OKD cluster, you can restrict access to only those in specific GitHub organizations.

Registering a GitHub application

Register an OAuth application on GitHub or GitHub Enterprise to obtain the client ID and client secret for the identity provider configuration.

Procedure
  1. Start the registration process by navigating to the appropriate page in GitHub or GitHub Enterprise:

    • For GitHub, click your profile picture in the upper right corner and select SettingsDeveloper settingsOAuth Apps.

    • For GitHub Enterprise, go to your GitHub Enterprise home page and then select Settings → Developer settings → Register a new application.

  2. Click New OAuth app.

  3. Enter an application name, for example My OpenShift Install.

  4. Enter a homepage URL, such as https://oauth-openshift.apps.<cluster-name>.<cluster-domain>.

  5. Optional: Enter an application description.

  6. Enter the authorization callback URL, where the end of the URL contains the identity provider name:

    https://oauth-openshift.apps.<cluster-name>.<cluster-domain>/oauth2callback/<idp-provider-name>

    For example:

    https://oauth-openshift.apps.openshift-cluster.example.com/oauth2callback/github
  7. Click Register application. GitHub provides a client ID and a client secret. You need these values to complete the identity provider configuration.

Creating the secret

Create a Secret object in the openshift-config namespace to store the client secret and related credentials for the identity provider configuration.

Procedure
  1. Create a Secret object containing the client secret by running the following command:

    $ oc create secret generic <secret_name> --from-literal=clientSecret=<secret> -n openshift-config
  2. Optional: Apply the following YAML to create the secret:

    apiVersion: v1
    kind: Secret
    metadata:
      name: <secret_name>
      namespace: openshift-config
    type: Opaque
    data:
      clientSecret: <base64_encoded_client_secret>
  3. Create a Secret object from a file by running the following command:

    $ oc create secret generic <secret_name> --from-file=<path_to_file> -n openshift-config

Creating a 'configmap'

Create a configmap object in the openshift-config namespace to store the certificate authority bundle that identity providers use to validate secure connections to the remote authentication service.

This procedure is required only for GitHub Enterprise.

Procedure
  1. Define an OKD configmap object containing the certificate authority by running the following command:

    $ oc create configmap ca-config-map --from-file=ca.crt=/path/to/ca -n openshift-config
  2. Optional: Apply the following YAML to create the config map:

    apiVersion: v1
    kind: configmap
    metadata:
      name: ca-config-map
      namespace: openshift-config
    data:
      ca.crt: |
        <CA_certificate_PEM>

    The certificate authority must be stored in the ca.crt key of the configmap object.

Sample GitHub CR

Review the custom resource fields and acceptable values for configuring a GitHub identity provider in OKD. Use these definitions to set client credentials and access restrictions before applying the configuration to the cluster.

apiVersion: config.openshift.io/v1
kind: OAuth
metadata:
  name: cluster
spec:
  identityProviders:
  - name: githubidp
    mappingMethod: claim
    type: GitHub
    github:
      ca:
        name: ca-config-map
      clientID: {...}
      clientSecret:
        name: github-secret
      hostname: ...
      organizations:
      - myorganization1
      - myorganization2
      teams:
      - myorganization1/team-a
      - myorganization2/team-b

where:

spec.identityProviders.name

Specifies the provider name, which is prefixed to the GitHub numeric user ID to form an identity name. It is also used to build the callback URL.

spec.identityProviders.mappingMethod

Specifies how mappings are established between identities from this provider and User objects.

spec.identityProviders.github.ca

Specifies an optional reference to an OKD configmap object containing the PEM-encoded certificate authority bundle to use in validating server certificates for the configured URL. Only for use in GitHub Enterprise with a non-publicly trusted root certificate.

spec.identityProviders.github.clientID

Specifies the client ID issued when you register a GitHub OAuth application. The application must be configured with a callback URL of https://oauth-openshift.apps.<cluster-name>.<cluster-domain>/oauth2callback/<idp-provider-name>.

spec.identityProviders.github.clientSecret

Specifies a reference to an OKD Secret object containing the client secret issued by GitHub.

spec.identityProviders.github.hostname

Specifies the hostname of your GitHub Enterprise instance, such as example.com. This value must match the GitHub Enterprise hostname value in the /setup/settings file and cannot include a port number. If this value is not set, then either teams or organizations must be defined. For GitHub, omit this parameter.

spec.identityProviders.github.organizations

Specifies the list of organizations. Either the organizations or teams field must be set unless the hostname field is set, or if mappingMethod is set to lookup. Cannot be used in combination with the teams field.

spec.identityProviders.github.teams

Specifies the list of teams. Either the teams or organizations field must be set unless the hostname field is set, or if mappingMethod is set to lookup. Cannot be used in combination with the organizations field.

If organizations or teams is specified, only GitHub users that are members of at least one of the listed organizations are allowed to log in. If the GitHub OAuth application configured in clientID is not owned by the organization, an organization owner must grant third-party access to use this option. This can be done during the first GitHub login by the administrator of the organization, or from the GitHub organization settings.

Additional resources

Adding an identity provider to your cluster

Apply the identity provider custom resource (CR) to your cluster so users can authenticate with the configured identity provider.

Prerequisites
  • You installed an OKD cluster.

  • You defined the CR for your identity provider.

  • You are logged in as an administrator.

Procedure
  1. Apply the defined CR by running the following command:

    $ 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. Obtain a token from the OAuth server.

    As long as the kubeadmin user has been removed, the oc login 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, by running the following command:

    $ oc login --token=<token>

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

  4. Confirm that the user logged in successfully and that the username displays by running the following command:

    $ oc whoami