If you're building a tool for developers, GitLab login belongs next to GitHub on your sign-in page. GitLab has over 30 million registered users, it dominates in enterprises that self-host their source control, and — here's the part that makes it uniquely interesting for this audience — GoTrue can authenticate against a self-managed GitLab instance, not just gitlab.com. If your company already runs GitLab on its own infrastructure, your self-hosted Supabase stack can use it as an identity provider with one extra environment variable.
As with every provider on a self-hosted instance, there's no dashboard toggle: the Studio UI doesn't manage auth providers, so everything happens through environment variables on the auth container. This guide covers the full setup — creating the GitLab OAuth application, configuring GoTrue, pointing it at a self-managed GitLab if you have one, and debugging the handful of errors that generate most of the forum threads. If you're wiring up several providers at once, start with our OAuth providers overview for self-hosted Supabase for the shared concepts; here we go deep on GitLab specifically.
Step 1: Create the GitLab OAuth Application
GitLab lets you register OAuth applications at three levels, and the right choice depends on who should own the credential:
- User-owned — Preferences → Applications on your GitLab profile. Fine for personal projects; the app dies with the account.
- Group-owned — Group → Settings → Applications. The right choice for team products: the credential belongs to the group, not an individual.
- Instance-wide — Admin Area → Applications. Only available on self-managed GitLab, useful when the app should exist independently of any group.
Whichever level you pick:
- Click Add new application and give it a name your users will recognize — GitLab displays it on the consent screen.
- Set the Redirect URI to your Supabase auth callback:
https://api.yourdomain.com/auth/v1/callback
This must be your Supabase API domain — the one your gateway (Envoy on current stacks, Kong on older ones) serves — not your frontend. GitLab is strict about exact matching here: scheme, host, and path all have to line up, and a trailing slash counts as a mismatch. If your instance still answers on a bare IP, sort out a proper custom domain first; GitLab shows the redirect host to users during consent.
- Leave Confidential checked. The OAuth exchange happens server-side in GoTrue, which can keep a secret — the confidential flow is the correct and safer option.
- Under Scopes, select
read_user. That's the only scope GoTrue's GitLab provider needs: it grants read access to the user's profile and email, nothing else. Don't grantapi— it's a far broader permission than a login flow should ever hold, and your users will (rightly) hesitate at a consent screen asking for full API access. - Save, then copy the Application ID and Secret. GitLab shows the secret only once.
Step 2: Configure GoTrue
Add the provider variables to the .env file your compose stack sources:
GOTRUE_EXTERNAL_GITLAB_ENABLED=true GOTRUE_EXTERNAL_GITLAB_CLIENT_ID=your-application-id GOTRUE_EXTERNAL_GITLAB_SECRET=your-secret GOTRUE_EXTERNAL_GITLAB_REDIRECT_URI=https://api.yourdomain.com/auth/v1/callback
Then make sure they actually reach the container. The stock Supabase docker-compose.yml uses explicit environment: mappings on the auth service, so a provider that isn't already listed needs to be added by hand:
auth:
environment:
GOTRUE_EXTERNAL_GITLAB_ENABLED: ${GOTRUE_EXTERNAL_GITLAB_ENABLED}
GOTRUE_EXTERNAL_GITLAB_CLIENT_ID: ${GOTRUE_EXTERNAL_GITLAB_CLIENT_ID}
GOTRUE_EXTERNAL_GITLAB_SECRET: ${GOTRUE_EXTERNAL_GITLAB_SECRET}
GOTRUE_EXTERNAL_GITLAB_REDIRECT_URI: ${GOTRUE_EXTERNAL_GITLAB_REDIRECT_URI}
Setting a variable in .env without the pass-through line is the single most common reason a provider "doesn't work" despite correct credentials — the container simply never sees it. Our environment variables guide for self-hosted Supabase covers this pattern across the whole stack. This is also exactly the kind of config-file surgery Supascale's provider configuration UI exists to replace — it writes the variables, wires the pass-through, and restarts the service for you.
Recreate the auth container (a restart is not enough — compose only re-reads .env on recreate):
docker compose up -d --force-recreate auth
Pointing at a Self-Managed GitLab
By default GoTrue talks to https://gitlab.com. To authenticate against your own GitLab instance, add one more variable (documented in Supabase's self-hosted OAuth guide):
GOTRUE_EXTERNAL_GITLAB_URL=https://gitlab.internal.yourcompany.com
Two requirements trip people up here:
- GoTrue must be able to reach that URL from inside its container. If your GitLab lives on a private network, the Supabase host needs a route to it — a VPN, a Tailscale network, or plain internal DNS.
docker compose exec auth wget -qO- https://gitlab.internal.yourcompany.comis a quick sanity check. - The TLS certificate must be valid. GoTrue won't accept a self-signed certificate it doesn't trust. Use a real certificate on the GitLab instance or mount your internal CA into the auth container.
Get both right and you have an entirely self-hosted identity chain: your GitLab, your Supabase, no third-party IdP anywhere in the login path. For teams with compliance requirements that's not a nice-to-have — it's the whole point.
Verify Before Touching the Frontend
Ask GoTrue directly what it has enabled rather than debugging through your app:
curl -s https://api.yourdomain.com/auth/v1/settings \ -H "apikey: $ANON_KEY" | jq '.external.gitlab'
If that returns true, the provider is live. If it returns false, the variables aren't reaching the container — recheck the pass-through and the recreate step before looking anywhere else.
Step 3: The Client Side
The frontend code is the standard signInWithOAuth call:
const { data, error } = await supabase.auth.signInWithOAuth({
provider: 'gitlab',
options: {
redirectTo: 'https://app.yourdomain.com/auth/callback',
},
});
The redirectTo value is where GoTrue sends the user after a successful exchange — it's separate from the OAuth redirect URI and must be allow-listed via GOTRUE_URI_ALLOW_LIST (or match your SITE_URL). Mixing up these two redirect concepts causes a steady stream of confusion; our redirect URLs and Site URL guide untangles them properly.
One behavioral note: GitLab access tokens expire after two hours and GoTrue does not refresh provider tokens for you. If you only use GitLab for login, this is irrelevant — Supabase issues its own session JWTs. But if you planned to keep using the provider_token to call the GitLab API on the user's behalf, you'll need to handle the provider's refresh token yourself or re-prompt the user.
Troubleshooting the Usual Suspects
"The redirect URI included is not valid" (from GitLab). Exact-match failure. Compare the URI in your GitLab application against GOTRUE_EXTERNAL_GITLAB_REDIRECT_URI character by character — http vs https, www, trailing slash. If you recently moved domains, the GitLab app still has the old one.
"Unsupported provider: provider is not enabled" (from GoTrue). The env vars aren't in the container. Verify with the /auth/v1/settings check above, then fix the compose pass-through. Also confirm you didn't typo the prefix — it's GITLAB, and unlike the LinkedIn OIDC provider, there's no variant suffix to worry about.
"Error getting user email from external provider." GitLab returns the user's primary email via the read_user scope, but only if it's confirmed. Users with unconfirmed addresses — common on fresh self-managed instances where SMTP wasn't configured and confirmation mails never arrived — fail at this step. Fix the email confirmation on the GitLab side, or have an admin confirm the user manually.
Login works on gitlab.com but not your self-managed instance. Almost always network or TLS: GoTrue can't reach GOTRUE_EXTERNAL_GITLAB_URL or doesn't trust its certificate. Check docker compose logs auth right after an attempt — GoTrue logs the upstream failure explicitly.
Callback returns 404. Your gateway isn't routing /auth/v1/callback to the auth service. On stacks that migrated from Kong to Envoy (the default since the August 2026 gateway change), a stale or hand-edited route config is the usual cause.
Managing This Across Projects
Everything above is a one-time cost for one project. The pain compounds when you run several instances — staging and production, or multiple projects on shared infrastructure — because each needs its own GitLab application (redirect URIs differ), its own set of env vars, and its own carefully executed container recreate. A typo in one of twelve GOTRUE_EXTERNAL_* lines fails silently until a user hits the broken provider.
Supascale turns that into a form: pick GitLab, paste the Application ID and Secret, optionally set a self-managed instance URL, and it handles the env plumbing and service restart per project. The auth providers documentation shows the flow, and because every tier is a one-time license with unlimited projects, the twelfth project costs the same as the first: nothing extra.
Wrapping Up
GitLab login on self-hosted Supabase comes down to four things: an OAuth application with the exact callback URI and only the read_user scope, four GOTRUE_EXTERNAL_GITLAB_* variables that actually reach the auth container, an allow-listed post-login redirect, and — the part no other provider gives you — an optional GOTRUE_EXTERNAL_GITLAB_URL that points the whole flow at your own GitLab instance. For developer tools and internal platforms, that last variable is quietly one of the best features in GoTrue: a login chain where every link runs on hardware you control.
