basetenlabs/octo-sts-app
forked from octo-sts/app
Captured source
source ↗basetenlabs/octo-sts-app
Description: A GitHub App that acts like a Security Token Service (STS) for the Github API
License: Apache-2.0
Stars: 0
Forks: 0
Open issues: 0
Created: 2026-11-10T20:37:09Z
Pushed: 2026-11-10T20:13:25Z
Default branch: main
Fork: yes
Parent repository: octo-sts/app
Archived: no
README:
octo-sts: an STS for GitHub
This repository holds a GitHub App called octo-sts that acts like a Security Token Service (STS) for the GitHub API. Using this App, workloads running essentially anywhere that can produce OIDC tokens can federate with this App's STS API in order to produce short-lived tokens for interacting with GitHub.
_The ultimate goal of this App is to wholly eliminate the need for GitHub Personal Access Tokens (aka PATs)._
The original blog post and the page on Chainguard Academy.
Getting started
1. Install the `octo-sts` App into your organization (or user account) and grant it access to the repositories your workloads need to interact with. 2. Check a [trust policy](#the-trust-policy) into .github/chainguard/{name}.sts.yaml in the repository (or in the organization's .github repository for org-level policies). 3. [Federate a token](#federating-a-token) from your workload. In GitHub Actions, use `octo-sts/action`:
permissions:
id-token: write
steps:
- uses: octo-sts/action@f603d3be9d8dd9871a265776e625a27b00effe05 # v1.1.1
id: octo-sts
with:
scope: my-org/my-repo
identity: my-policy
- run: gh issue list -R my-org/my-repo
env:
GH_TOKEN: ${{ steps.octo-sts.outputs.token }}Setting up workload trust
For the App to produce credentials that work with resources in your organization it must be installed into the organization and have access to any repositories that you will want workloads to be able to interact with. Unfortunately due to limitations with GitHub Apps, the App must ask for a superset of the permissions needed for federation, so the full set of permissions the App requests will be large, but with one exception (contents: read reading policy files) the App only creates tokens with these scopes based on the "trust policies" you have configured.
Organizations with an IP allow list
The hosted service at octo-sts.dev does not support GitHub organizations that enforce an IP allow list. The hosted service reaches GitHub from shared cloud IP addresses that change over time, so you cannot add them to an allow list. GitHub rejects its requests, and token exchanges fail with a 403 and GitHub denied access to (403): check the org's IP allow list, or whether the octo-sts installation is suspended. This diagnostic also covers token minting for trust policy reads and the final exchange token when the organization trusted-issuer lookup is cached. Trust policy permission denials are cached for up to one minute to avoid repeated requests. Responses carrying rate-limit markers keep their existing handling.
These organizations should self-host octo-sts with their own GitHub App and a static egress IP, then add that IP to the allow list. The Terraform module in [modules/app](./modules/app) is a starting point, but it hard-codes egress = "PRIVATE_RANGES_ONLY", so GitHub traffic does not use your network. A static egress IP means changing the module to ALL_TRAFFIC egress and adding Cloud NAT. See #1818 for details.
The Trust Policy
Trust policies are checked into .github/chainguard/{name}.sts.yaml (the directory is configurable for self-hosted deployments; see [OCTOSTS_POLICY_DIR](#custom-policy-directory-octosts_policy_dir)), and consist of a few key parts:
1. The claim matching criteria for federation, 2. The permissions to grant the identity, and 3. (for Org-level policies) The list of repositories to grant access.
Here is a simple example that allows the GitHub actions workflows in chainguard-dev/foo running on the main branch to read the repo contents and interact with issues:
# yaml-language-server: $schema=https://raw.githubusercontent.com/octo-sts/app/refs/heads/main/pkg/octosts/octosts.TrustPolicy.json issuer: https://token.actions.githubusercontent.com subject: repo:chainguard-dev/foo:ref:refs/heads/main permissions: contents: read issues: write
The same policy with GitHub's immutable subject claims, which embed the owner and repository IDs in the subject (repo:@/@:...):
# yaml-language-server: $schema=https://raw.githubusercontent.com/octo-sts/app/refs/heads/main/pkg/octosts/octosts.TrustPolicy.json issuer: https://token.actions.githubusercontent.com subject: repo:chainguard-dev@87436699/foo@123456789:ref:refs/heads/main permissions: contents: read issues: write
Unlike the name-only subject, an immutable subject cannot be matched by a different organization or repository that later takes over the same name, so we recommend it for GitHub Actions trust policies.
Which form a repository's tokens carry depends on the repository. Per GitHub's changelog, repositories created, renamed or transferred after July 15, 2026 use immutable subject claims by default. Older repositories keep the name-only subject (repo:/:...) until someone opts in, so a policy written for one form does not match tokens of the other and the token exchange fails. To check or change the setting for a repository, open its https://github.com///settings/actions/oidc-configuration page and check Use immutable subject claim. The page also shows the exact Default subject claim prefix (for example repo:chainguard-dev@87436699/foo@123456789) to use in your trust policy.
The Trust Policy can also match the issuer, subject, and even custom claims with regular expressions. For example:
# yaml-language-server:...
Excerpt shown — open the source for the full document.