Share credentials with GitHub

Register GitHub Apps and store the credentials in Red Hat Developer Hub to enable secure communication. For security, create two separate GitHub Apps following the principle of least privilege:

Before you begin

About this task

Integration App (Developer Hub to GitHub)
Authenticates Developer Hub to GitHub for catalog operations such as importing users, groups, and repositories. Requires: GITHUB_APP_APP_ID, GITHUB_APP_CLIENT_ID_INTEGRATION, GITHUB_APP_CLIENT_SECRET_INTEGRATION, and GITHUB_APP_PRIVATE_KEY.
Authentication App (user to Developer Hub)
Authenticates users signing in to Developer Hub with their GitHub credentials. Requires only OAuth credentials: GITHUB_APP_CLIENT_ID and GITHUB_APP_CLIENT_SECRET.

Procedure

  1. Create a GitHub App for integration.
    Note

    Use a GitHub App instead of an OAuth app to use fine-grained permissions and short-lived tokens, scale with the number of installations by avoiding rate limits, and have a more transparent integration by avoiding to request user input.

    1. Register a GitHub App with the following configuration:
      GitHub App name
      Enter a unique name identifying your GitHub App, such as integrating-with-rhdh-<GUID>.
      Homepage URL
      Enter your Developer Hub URL: https://<my_developer_hub_domain>.
      Webhook
      Clear "Active".
      Repository permissions
      Contents
      Read-only
      Commit statuses
      Read-only
      Organization permissions
      Members
      Read-only
      Where can this GitHub App be installed?
      Select Only on this account.
    2. In the General Clients secrets section, click Generate a new client secret.
    3. In the General Private keys section, click Generate a private key.
    4. In the Install App tab, choose an account to install your GitHub App on.
    5. Save the following values for the next step:
      • App ID
      • Client ID
      • Client secret
      • Private key
  2. Store the integration app credentials: Add the following key/value pairs to your Developer Hub secrets.
    GITHUB_APP_APP_ID
    Enter the saved App ID.
    GITHUB_APP_CLIENT_ID_INTEGRATION
    Enter the saved Client ID.
    GITHUB_APP_CLIENT_SECRET_INTEGRATION
    Enter the saved Client Secret.
    GITHUB_APP_PRIVATE_KEY
    Enter the saved Private key.
    GITHUB_HOST
    Enter the GitHub hostname without a scheme, such as github.com. The integrations.github host expects a hostname only; a URL such as https://github.com fails integration validation.
    GITHUB_ORG
    Enter your GitHub organization name, such as <your_github_organization_name>.
  3. Create a separate GitHub App for authentication.
    1. Register a GitHub App with the following configuration:
      GitHub App name
      Enter a unique name identifying your GitHub App, such as authenticating-with-rhdh-<GUID>.
      Homepage URL
      Enter your Developer Hub URL: https://<my_developer_hub_domain>.
      Authorization callback URL
      Enter your Developer Hub authentication backend URL: https://<my_developer_hub_domain>/api/auth/github/handler/frame.
      Webhook
      Clear "Active".
      Organization permissions
      Enable Read-only access to Members.
      Where can this GitHub App be installed?
      Select Only on this account.
    2. In the General Clients secrets section, click Generate a new client secret.
    3. Save the following values for the next step:
      • Client ID
      • Client secret
  4. Store the authentication app credentials: Add the following key/value pairs to your Developer Hub secrets.
    GITHUB_APP_CLIENT_ID
    Enter the saved Client ID.
    GITHUB_APP_CLIENT_SECRET
    Enter the saved Client Secret.

Results

  • Verify that the secret key-value pairs for both apps are stored in your Developer Hub secrets.