Skip to main content
OIDC Federation Beyond GitHub: GitLab, Buildkite, and Generic Providers

OIDC Federation Beyond GitHub: GitLab, Buildkite, and Generic Providers

KU
· Founder & Chief Editor
• 7 min read•Updated •

GitHub Actions OIDC gets all the attention, but GitLab, Buildkite, and CircleCI issue the same signed tokens. This is how to trust them without opening a hole.

Key takeaways

  • GitLab, Buildkite and CircleCI are all OIDC identity providers, so they can assume cloud roles with short-lived tokens exactly like GitHub Actions.
  • Register each issuer, then pin the exact sub and aud claims in the trust policy.
  • Each CI system formats sub differently, and a wildcard on the project part hands your role to strangers.

You don't need static cloud keys for GitLab, Buildkite or CircleCI: each is an OIDC identity provider. Register its issuer with your cloud and pin the exact sub and aud claims in the role's trust policy, as with GitHub Actions. Only the issuer URL and subject format change, and the subject is where people cut themselves.

Verified against

GitLab id_tokens (docs current through GitLab 19.5), Buildkite agent oidc request-token, CircleCI OIDC tokens (V1 to V3 formats), against the GitLab, Buildkite, CircleCI and AWS IAM documentation. Checked October 2026.

Most teams that adopt keyless authentication do it for GitHub Actions first, because that's where the tutorials point. Then a pipeline moves to GitLab, or the platform team standardizes on Buildkite, and someone asks whether the other CI systems go back to static keys. No. The pattern is the one we documented for OIDC federation from GitHub Actions to AWS.

The shape is the same everywhere

An OIDC provider does one job for you: it signs a JWT describing the running job and publishes a JWKS document so anyone can verify the signature. The cloud side does the rest. You register the provider once (its issuer URL and allowed audiences; AWS now verifies the JWKS endpoint's TLS certificate against trusted root CAs and only falls back to a configured thumbprint when it can't), then write a role trust policy that pins three things:

  • issuer (iss): which provider signed this, so a token from some other GitLab instance can't walk in
  • subject (sub): which specific job, keyed to project, branch, environment, or pipeline
  • audience (aud): who the token was minted for, so a token meant for someone else's API can't be replayed against your role

Validate those three correctly and there is nothing to leak. The token lives for the length of the job and is scoped to a role that can only do what that job needs. Get the subject match wrong and you've built a very modern way to hand your account to a stranger.

GitLab CI: id_tokens

GitLab retired CI_JOB_JWT and deprecated its _V2 successor. The current mechanism is explicit id_tokens, where you name the audience and GitLab injects the token as an env var. The issuer is your GitLab instance URL (https://gitlab.com for SaaS, your own host for self-managed), and aud defaults to that same instance URL if you don't set it.

.gitlab-ci.yml
deploy:
  stage: deploy
  image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest
  id_tokens:
    AWS_ID_TOKEN:
      aud: https://gitlab.com   # must match the trust policy exactly
  script:
    - >
      export $(aws sts assume-role-with-web-identity
      --role-arn "$AWS_ROLE_ARN"
      --role-session-name "gitlab-$CI_JOB_ID"
      --web-identity-token "$AWS_ID_TOKEN"
      --duration-seconds 900
      --query 'Credentials.[AccessKeyId,SecretAccessKey,SessionToken]'
      --output text | awk '{print "AWS_ACCESS_KEY_ID="$1"\nAWS_SECRET_ACCESS_KEY="$2"\nAWS_SESSION_TOKEN="$3}')
    - aws sts get-caller-identity

The AWS trust policy that accepts it. The default subject format is project_path:GROUP/PROJECT:ref_type:TYPE:ref:BRANCH, and a project can change it through the projects API, so check what your instance actually emits.

JSON
# iam/gitlab-deploy-trust.json (one Statement entry)
{
  "Effect": "Allow",
  "Principal": { "Federated": "arn:aws:iam::123456789012:oidc-provider/gitlab.com" },
  "Action": "sts:AssumeRoleWithWebIdentity",
  "Condition": {
    "StringEquals": {
      "gitlab.com:aud": "https://gitlab.com",
      "gitlab.com:sub": "project_path:acme/payments:ref_type:branch:ref:main"
    }
  }
}

That subject pins the role to the main branch of one project. A merge request pipeline or a fork gets a different sub and is rejected.

Buildkite

Buildkite exposes OIDC through the agent CLI rather than an env var, which is cleaner because the token is requested at the moment it's needed and expires after 5 minutes by default (--lifetime changes it). Issuer is https://agent.buildkite.com; the default aud is https://buildkite.com/ORG_SLUG, so pass --audience to match your trust policy.

.buildkite/pipeline.yml
steps:
  - label: "deploy"
    command: |
      export AWS_WEB_IDENTITY_TOKEN_FILE=$(mktemp)
      buildkite-agent oidc request-token \
        --audience "sts.amazonaws.com" \
        > "$AWS_WEB_IDENTITY_TOKEN_FILE"
      export AWS_ROLE_ARN="arn:aws:iam::123456789012:role/buildkite-deploy"
      aws sts get-caller-identity

Buildkite's default subject is organization:ORG_SLUG:pipeline:PIPELINE_SLUG:ref:REF:commit:COMMIT:step:STEP_KEY. Because the commit and step are in there, don't try to match the whole string. Pin the stable prefix including the ref, and let only the commit and step float:

JSON
# iam/buildkite-deploy-trust.json (Condition block)
"Condition": {
  "StringEquals": { "agent.buildkite.com:aud": "sts.amazonaws.com" },
  "StringLike":   { "agent.buildkite.com:sub": "organization:acme:pipeline:api-deploy:ref:refs/heads/main:*" }
}

The token also carries dedicated claims (organization_slug, pipeline_slug, build_branch), and --subject-claim can replace the composite sub with a single immutable value such as cluster_id.

CircleCI and the generic case are the same story with different strings. CircleCI's issuer is https://oidc.circleci.com/org/ORG_ID, its default aud is the organization ID, and $CIRCLE_OIDC_TOKEN carries sub as org/ORG_ID/project/PROJECT_ID/user/USER_ID; $CIRCLE_OIDC_TOKEN_V2 appends the VCS origin and ref, which is the one to use if you want to pin a branch. Any conformant provider (HashiCorp Vault, an internal Spinnaker, a Kubernetes service account issuer) plugs in the same way: register the issuer, verify the JWKS is reachable, pin sub and aud.

Three gotchas that bite

Wildcard subjects are a footgun. StringLike with project_path:acme/* on GitLab, or sub: repo:myorg/* on GitHub, means any project or repo under that namespace can assume the role. Fine for a throwaway sandbox, a standing breach for anything with real permissions. Match the exact sub unless you have a documented reason not to, and when you do wildcard, wildcard the branch, never the project.

Audience has to match byte for byte. GitLab defaults aud to the instance URL, Buildkite to https://buildkite.com/ORG_SLUG, CircleCI to the org ID, and none of those is sts.amazonaws.com. If the token says one thing and the trust policy checks another, you get an opaque AccessDenied with no hint why. Decode the JWT payload locally (never paste a live token into a website) and read the actual claims before you go debugging IAM:

Bash
python3 -c 'import sys,json,base64; p=sys.argv[1].split(".")[1]; c=json.loads(base64.urlsafe_b64decode(p+"="*(-len(p)%4))); print({k: c.get(k) for k in ("iss","sub","aud")})' "$AWS_ID_TOKEN"

The issuer's JWKS endpoint must be reachable from the validator. For self-managed GitLab behind a firewall, or an air-gapped runner, the cloud provider fetches /.well-known/openid-configuration and the JWKS URL it points to. If that path isn't publicly resolvable with a valid, correctly ordered TLS chain, STS rejects the token with InvalidIdentityToken ("Couldn't retrieve verification key from your identity provider"). This is the most common reason self-hosted OIDC "works in the demo, breaks in prod."

Questions people ask

What is the sub claim format for GitLab OIDC tokens?

By default GitLab sets sub to project_path:GROUP/PROJECT:ref_type:TYPE:ref:BRANCH, for example project_path:acme/payments:ref_type:branch:ref:main. The issuer is your GitLab instance URL and aud defaults to that URL unless you set it under id_tokens. Projects can customize the sub format through the projects API, so decode a real token from your pipeline before you write the AWS trust policy.

Why does AssumeRoleWithWebIdentity return AccessDenied from GitLab or Buildkite?

Almost always a claim mismatch. Check three things in the decoded token: iss matches the registered provider URL exactly, aud matches the audience in both the IAM provider and the trust policy condition, and sub matches your StringEquals or StringLike pattern. Buildkite's default audience is https://buildkite.com/ORG_SLUG, not sts.amazonaws.com, so pass --audience explicitly. An InvalidIdentityToken error instead points at JWKS or TLS reachability.

Do I still need a thumbprint for an OIDC provider in AWS?

Usually not. AWS verifies the provider's JWKS endpoint TLS certificate against its library of trusted root certificate authorities and only uses the thumbprints you configured when the certificate isn't signed by one of those CAs, or when it can't retrieve the certificate. Self-managed GitLab behind a private CA is the case where the thumbprint still matters.

The call we'd make

Standardize on OIDC across every CI system before you standardize on the CI system itself. The token shape is portable; the static-key habit is not. Register each provider, pin the exact sub and aud, and treat any wildcard in a subject claim as a change that needs a second reviewer. The five minutes you spend reading the actual JWT claims will save the afternoon you'd otherwise lose to a silent AccessDenied.

Sources

Explore topics:CI/CDSecurityDevOps
React
Share this post
Cite this article
Plain text

Kiril Urbonas (2026). OIDC Federation Beyond GitHub: GitLab, Buildkite, and Generic Providers. DevOpsNess. Updated 2026-11-15. https://www.devopsness.com/blog/oidc-federation-beyond-github-gitlab-buildkite

Markdown

[OIDC Federation Beyond GitHub: GitLab, Buildkite, and Generic Providers](https://www.devopsness.com/blog/oidc-federation-beyond-github-gitlab-buildkite) (Kiril Urbonas, DevOpsNess, updated 2026-11-15)

KU

Kiril Urbonas

Founder & Chief Editor

606 articles
View all articles by Kiril Urbonas

You might have missed

Evergreen posts worth revisiting.