---
title: "GitLab.com"
description: "Let GitLab.com CI/CD jobs call Limrun with their ID token instead of a stored API key."
canonical_url: "https://docs.limrun.com/docs/access/workload-identity-federation/gitlab"
markdown_url: "https://docs.limrun.com/docs/access/workload-identity-federation/gitlab.md"
last_updated: "2026-11-26"
x_farming_labs_generated_preamble: true
---

# GitLab.com
URL: /docs/access/workload-identity-federation/gitlab
LLM index: /llms.txt
Description: Let GitLab.com CI/CD jobs call Limrun with their ID token instead of a stored API key.

# Authenticate GitLab.com CI/CD with workload identity federation

A GitLab CI/CD job can receive an ID token from GitLab and exchange it for a short-lived Limrun access token. Your projects then need no `LIM_API_KEY` variable, and you control which projects and branches get which permissions. This page covers GitLab.com. For a self-managed GitLab instance, see [Self-managed GitLab](#self-managed-gitlab).

## Before you start

You need:

- The `admin` role in your Limrun organization.
- The numeric ID of the GitLab group that directly contains your projects. On the group's overview page, select **Actions** (⋮) in the upper-right corner, then **Copy Group ID**.

## Create the provider

GitLab.com signs tokens for every project on GitLab.com, so the provider condition must check that a token comes from your group.

1. Open [console.limrun.com](https://console.limrun.com), go to **Settings**, then **Workload identity federation**, and click the **+** button next to **Identity providers**.
2. In **Issuer**, choose **GitLab.com**. The preset fills in the issuer `https://gitlab.com` and its signing keys at `https://gitlab.com/oauth/discovery/keys`.
3. Keep **Token audience** as `limrun`. The job requests its token with this audience.
4. In **Provider condition (CEL)**, replace `NAMESPACE_ID` with your group ID:

   ```text
   assertion.namespace_id == 'NAMESPACE_ID'
   ```

   GitLab sends IDs as strings, so keep the quotes. Use the ID rather than the path, because IDs don't change when a group is renamed.
5. Click **Create provider**.

## Create a binding

1. In the provider's card, click the **+** button next to **Bindings**.
2. Enter a name and a **Claim condition (CEL)** that selects the jobs to trust. For example, this admits only the `main` branch of one project:

   ```text
   assertion.project_id == 'PROJECT_ID' && assertion.ref == 'main'
   ```

   Run `glab api projects/YOUR_GROUP%2FYOUR_PROJECT | jq .id` to find the project ID. GitLab's `ref` claim is the short branch name, such as `main`; the full ref is in `ref_path`.
3. Enter the permissions the jobs need, one per line, such as `xcode:*:all`.
4. Click **Create binding**, expand **Setup**, and copy the binding ID.

## Use the token in a job

Name the job's ID token `LIMRUN_WORKLOAD_IDENTITY_TOKEN`, and the CLI picks it up directly:

```yaml title=".gitlab-ci.yml"
limrun:
  image: node:22
  id_tokens:
    LIMRUN_WORKLOAD_IDENTITY_TOKEN:
      aud: limrun
  variables:
    LIMRUN_WORKLOAD_IDENTITY_BINDING_ID: binding_REPLACE_WITH_BINDING_ID
  script:
    - npm install --global lim
    - lim whoami
```

`id_tokens` tells GitLab to put a token with the audience `limrun` in the variable you name, and `aud` must match the provider's audience. The binding ID is not a secret. The token expires at the job's timeout, or after five minutes if the job has none, so set a timeout that covers your Limrun steps. After `lim whoami` shows your organization and the binding's permissions, replace it with your build steps.

The SDKs read the same variables, so a script in the job needs no extra configuration.

## Things to know

- **Merge requests from forks carry the fork's IDs.** In a merge request pipeline, `namespace_id` and `project_id` describe the source project, so jobs from a fork in another group don't match your provider.
- **Match on IDs, not `sub`.** GitLab's default subject is `project_path:{group}/{project}:ref_type:{type}:ref:{branch_name}`, and projects can customize it. `namespace_id`, `project_id`, and `ref` stay stable.

## Self-managed GitLab

A self-managed instance signs only for itself, so it needs no owner check. In **Issuer**, choose **Other identity provider**. Enter your instance's URL, such as `https://gitlab.example.com`, as the issuer and `https://gitlab.example.com/oauth/discovery/keys` as the JWKS URL. Limrun must be able to reach the JWKS URL from the internet.

See [GitLab's ID token reference](https://docs.gitlab.com/ci/secrets/id_token_authentication/) for every claim in the token.

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
Docs-scoped sitemap: [/docs/sitemap.md](/docs/sitemap.md).
Well-known sitemap: [/.well-known/sitemap.md](/.well-known/sitemap.md).
