Configuring OAuth 2.0 for GitHub
To enable users to work with a remote Git repository that is hosted on GitHub:
-
Set up the GitHub App or Oauth App (OAuth 2.0).
-
Apply the GitHub OAuth App Secret.
Setting up the GitHub OAuth App
Set up a GitHub OAuth App using OAuth 2.0.
-
You are logged in to GitHub.
-
Enter the following values:
-
Application name:
<application name> -
Homepage URL:
https://<che_fqdn>/ -
Authorization callback URL:
https://<che_fqdn>/api/oauth/callback
-
-
Click Register application.
-
Click Generate new client secret.
-
Copy and save the GitHub OAuth Client ID for use when applying the GitHub OAuth App Secret.
-
Copy and save the GitHub OAuth Client Secret for use when applying the GitHub OAuth App Secret.
Setting up the GitHub App
Set up a GitHub App using OAuth 2.0.
-
You are logged in to GitHub.
-
Register a GitHub app, see: https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app#registering-a-github-app.
-
Enter the following values:
-
GitHub App name:
<application name> -
Homepage URL:
https://<che_fqdn>/ -
Callback URL:
https://<che_fqdn>/api/oauth/callback -
Deselect the
Activecheck-box in theWebhooksection. -
Add the
Read and WriteRepository permission forContents, see: https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app#registering-a-github-app.
-
-
Click Create GitHub App.
-
Click Generate a new client secret.
-
Copy and save the GitHub App Client Secret for use when applying the GitHub App Secret.
-
Copy and save the GitHub App Client ID for use when applying the GitHub App Secret.
Applying the GitHub OAuth App Secret
Prepare and apply the GitHub OAuth App Secret.
-
Setting up the GitHub OAuth App is completed.
-
The following values, which were generated when setting up the GitHub OAuth App, are prepared:
-
GitHub OAuth Client ID
-
GitHub OAuth Client Secret
-
-
An active
kubectlsession with administrative permissions to the destination Kubernetes cluster. See Overview of kubectl.
-
Prepare the Secret:
kind: Secret apiVersion: v1 metadata: name: github-oauth-config namespace: eclipse-che (1) labels: app.kubernetes.io/part-of: che.eclipse.org app.kubernetes.io/component: oauth-scm-configuration annotations: che.eclipse.org/oauth-scm-server: github che.eclipse.org/scm-server-endpoint: <github_server_url> (2) che.eclipse.org/scm-github-disable-subdomain-isolation: 'false' (3) type: Opaque stringData: id: <GitHub_OAuth_Client_ID> (4) secret: <GitHub_OAuth_Client_Secret> (5)1 The Che namespace. The default is eclipse-che.2 This depends on the GitHub product your organization is using: When hosting repositories on GitHub.com or GitHub Enterprise Cloud, omit this line or enter the default https://github.com. When hosting repositories on GitHub Enterprise Server, enter the GitHub Enterprise Server URL.3 If you are using GitHub Enterprise Server with a disabled subdomain isolation option, you must set the annotation to true, otherwise you can either omit the annotation or set it tofalse.4 The GitHub OAuth Client ID. 5 The GitHub OAuth Client Secret. -
Apply the Secret:
$ kubectl apply -f - <<EOF <Secret_prepared_in_the_previous_step> EOF
-
Verify in the output that the Secret is created.
To configure OAuth 2.0 for another GitHub provider, you have to repeat the steps above and create a second GitHub OAuth Secret with a different name.