Skip to content

Connect mail and GitHub or Google sign-in

Before you begin

You need
  • Shell access to the host, as a user who may use Docker
  • An SMTP relay the host can reach

A self-hosted installation sends its email through your mail relay, and can let people sign in with GitHub or Google. Both are settings in .env, applied by running ./mockhub install again.

Without working mail nobody can reset a password, accept an invitation or verify an address, so the relay is required.

  1. Set the relay and the sender in .env:

    Terminal window
    MAILER_DSN=smtp://mockhub:secret@smtp.example.com:587
    MAILER_FROM_ADDRESS=mockhub@example.com
    MAILER_FROM_NAME=MockHub

    Encode any special character in the user name or password for a URL, such as @ as %40.

  2. Set the mailboxes the installation names: SUPPORT_EMAIL, which emails name and replies reach, ABUSE_EMAIL and SECURITY_EMAIL.

  3. Run ./mockhub install.

Send yourself a password reset from the sign-in page to check it end to end. Emails link to the installation’s own app and documentation, and their replies go to SUPPORT_EMAIL.

  1. In GitHub, under your organisation’s Settings → Developer settings → OAuth Apps, register a new OAuth app.

  2. Set its homepage URL to the app’s address, https://UI_HOST, and its authorization callback URL to:

    https://API_HOST/auth/oauth/github/callback

    with your API_HOST, such as https://api.mockhub.example.com/auth/oauth/github/callback.

  3. Generate a client secret, and set both halves in .env:

    Terminal window
    OAUTH_GITHUB_CLIENT_ID=Ov23li...
    OAUTH_GITHUB_CLIENT_SECRET=...
  4. Run ./mockhub install.

MockHub asks GitHub for read:user and user:email, and uses the account’s primary verified address.

  1. In the Google Cloud console, create an OAuth client of type Web application for your organisation’s project.

  2. Add this authorized redirect URI, with your API_HOST:

    https://API_HOST/auth/oauth/google/callback
  3. Set the client’s ID and secret in .env:

    Terminal window
    OAUTH_GOOGLE_CLIENT_ID=1234567890-abc.apps.googleusercontent.com
    OAUTH_GOOGLE_CLIENT_SECRET=...
  4. Run ./mockhub install.

MockHub asks Google for openid, email and profile.

The sign-in page offers GitHub or Google, under Or continue with, once the provider’s client ID is set; without one, that button is not offered. A first sign-in with a provider creates an account only when the registration mode admits its address, and takes a licence seat like any new account.

  • Set both halves of a pair or neither. The button appears as soon as the client ID is set, and with no secret every sign-in through it fails.
  • GitHub and Google are the only providers. There is no SAML, OIDC or other single sign-on.
  • The callback is on API_HOST, not on the app’s host. A provider that still names an old hostname refuses the sign-in after a hostname change, until you update its callback.
  • Signing in with a provider needs the host to reach it: GitHub’s or Google’s servers, on the internet.

Report a problem with this page