Skip to main content

OIDC Tokens

This page describes how OpenID Connect (OIDC) tokens are generated.

Reference

Semaphore generates a unique OIDC token for every job. The token is injected into the job environment as a variable named SEMAPHORE_OIDC_TOKEN.

The token consists of a JWT token signed by Semaphore and contains the following claims.

Sure, here is the reordered list presented in a table with three columns: Claim, Description, Example.

ClaimDescriptionExample
issThe issuer of the token. The full URL of the organizationhttps://{org-name}.semaphoreci.com
audThe intended audience of the token. The full URL of the organizationhttps://{org-name}.semaphoreci.com
subThe subject of the token. A combination of org, project, repository, and git reference for which this token was issued
Template:
org:{org-name}:
project:{project-id}:
repo:{repo-name}:
ref_type:{branch or pr or tag}:
ref:{git_reference}
org:{org-name}:
project:936a5312-a3b8-4921-8b3f-2cec8baac574:
repo:web:
ref_type:branch:
ref:refs/heads/main
expThe UNIX timestamp when the token expires1660317851
iatThe UNIX timestamp when the token was issued1660317851
nbfThe UNIX timestamp before which the token is not valid1660317851
jtiThe Unique ID of the JWT token2s557dchalv2mv76kk000el1
branchThe name of the branch on which the job is running. If the job was triggered by a pull request, then the value is the target branch of the pull request that triggered that jobmain
pr_branchThe name of the source branch of the Pull Request which triggered a jobfeature-branch
prThe number of the Pull Request for which the token was issued123
refThe full git reference for which the token was issuedrefs/heads/main
ref_typeThe type of git reference that triggered the jobbranch, tag, or pull-request
tagThe name of the git tag for which the token was issuedv1.0.0
repoThe name of the repository for which the token was issuedweb
repo_slugSpecifies the repository's name in the format owner_name/repository_name for the current Semaphore project. It is associated with the environment variable SEMAPHORE_GIT_REPO_SLUGsemaphoreci/docs
prj_idThe project ID for which the token was issued1e1fcfb5-09c0-487e-b051-2d0b5514c42a
wf_idThe ID of the workflow for which the token was issued1be81412-6ab8-4fc0-9d0d-7af33335a6ec
ppl_idThe pipeline ID for which the token was issued1e1fcfb5-09c0-487e-b051-2d0b5514c42a
job_typeThe type of the job based on the way it was created
The possible values are:
  • pipeline_job: A regular job that is the part of a pipeline
  • debug_job: A job that was created to debug the other job via the sem debug job <JOB_ID> command
  • project_debug_job:A job that was created to debug the project via the sem debug project <PROJECT_NAME> command
pipeline_job
job_idThe ID of the job for which the token was issuedc117e453-1189-4eaf-b03a-dd6538eb49b2

A token with the above claims is exported into jobs as the SEMAPHORE_OIDC_TOKEN environment variable, which can then be presented to the cloud provider as an authorization token.

If the cloud provider is configured to accept OIDC tokens, it will receive the token, verify its signature by connecting back to {org-name}.semaphoreci.com.well-known/jwts, and if the token is valid, it will respond with a short-lived token for this specific job that can be used to fetch and modify cloud resources.

See also