Enable authentication with GitHub

Configure GitHub as your Red Hat Developer Hub sign-in provider.

Before you begin

Procedure

  1. Enable the GitHub authentication provider plugin in your dynamic-plugins.yaml file:
    plugins:
      - package: oci://quay.io/rhdh/backstage-plugin-auth-backend-module-github-provider:{{inherit}}
        enabled: true
  2. Add a GitHub authentication provider section to your app-config.yaml file:
    auth:
      environment: production
      providers:
        github:
          production:
            clientId: ${GITHUB_APP_CLIENT_ID}
            clientSecret: ${GITHUB_APP_CLIENT_SECRET}
    signInPage: github
    environment
    Enter production to disable the Guest login option in the Developer Hub login page.
    clientId
    Enter the configured secret variable name: ${GITHUB_APP_CLIENT_ID}.
    clientSecret
    Enter the configured secret variable name: ${GITHUB_APP_CLIENT_SECRET}.
    signInPage
    Enter github to enable the GitHub provider as your Developer Hub sign-in provider.
  3. Optional: Add optional fields to the GitHub authentication provider section in your app-config.yaml file:
    auth:
      environment: production
      providers:
        github:
          production:
            clientId: ${GITHUB_APP_CLIENT_ID}
            clientSecret: ${GITHUB_APP_CLIENT_SECRET}
            callbackUrl: <your_intermediate_service_url/handler>
            sessionDuration: { hours: 24 }
            signIn:
              resolvers:
                - resolver: userIdMatchingUserEntityAnnotation
                  dangerouslyAllowSignInWithoutUserInCatalog: true
    signInPage: github
    callbackUrl
    Enter the callback URL that GitHub uses when initiating an OAuth flow, such as: <your_intermediate_service_url/handler>. Define it when Developer Hub is not the immediate receiver, such as in cases when you use one OAuth app for many Developer Hub instances.
    sessionDuration
    Enter the user session lifespan, in ms library format (such as '24h', '2 days'), ISO duration, or "human duration".
    signIn
    resolvers

    After successful authentication, Developer Hub resolves the user signing in to an existing user in the Developer Hub catalog. Configure a specific resolver to best match users securely for your use case..

    Enter the resolver list to override the default resolver: userIdMatchingUserEntityAnnotation.

    The authentication provider tries each sign-in resolver in order until it succeeds. If none of the attempts succeed, the sign-in fails.

    Warning

    In production mode, configure only one resolver to make sure users are securely matched.

    resolver
    Enter the sign-in resolver name. Available resolvers: userIdMatchingUserEntityAnnotation, preferredUsernameMatchingUserEntityName, emailMatchingUserEntityProfileEmail.
    dangerouslyAllowSignInWithoutUserInCatalog

    Enter true to configure the sign-in resolver to bypass the user provisioning requirement in the Developer Hub software catalog.

    Warning

    In production mode, do not enable dangerouslyAllowSignInWithoutUserInCatalog.

  4. To disable the guest login option, in the app-config.yaml file, set the authentication environment to production:
    auth:
      environment: production

Results

  1. Go to the Developer Hub login page.
  2. Your Developer Hub sign-in page displays Sign in using GitHub and the Guest user sign-in is disabled.
  3. Log in with a GitHub account.