github-sts

by Depthmark

Helm chartv0.1.3App 0.1.2Verified publisher

GitHub Security Token Service (STS) - OIDC to GitHub token exchange

About this chart

github-sts

A Kubernetes Helm chart for deploying github-sts — a Python-based Security Token Service (STS) for the GitHub API.

Workloads with OIDC tokens (GitHub Actions, Azure, Google Cloud, etc.) exchange them for short-lived, scoped GitHub installation tokens. No PATs required. Supports multiple GitHub Apps with YAML-based configuration (ideal for Kubernetes ConfigMaps).

Homepage: https://github.com/Depthmark/github-sts-helm

Source Code

Prerequisites

  • Kubernetes 1.19+
  • Helm 3.0+
  • At least one GitHub App registered with the required permissions
  • A Kubernetes Secret containing the GitHub App private key, or the key imported into Azure Key Vault (see App keys in Azure Key Vault)

Installation

From OCI Registry (recommended)

# Create a secret with your GitHub App private key
kubectl create secret generic my-github-app-credentials \
  --from-file=github-app-private-key=/path/to/private_key.pem

# Install the chart
helm install github-sts oci://ghcr.io/depthmark/charts/github-sts \
  --set github.apps.default.appId="YOUR_GITHUB_APP_ID" \
  --set github.apps.default.existingSecret="my-github-app-credentials"

From Source

git clone https://github.com/Depthmark/github-sts-helm.git
cd github-sts-helm

kubectl create secret generic my-github-app-credentials \
  --from-file=github-app-private-key=/path/to/private_key.pem

helm install github-sts charts/github-sts \
  --set github.apps.default.appId="YOUR_GITHUB_APP_ID" \
  --set github.apps.default.existingSecret="my-github-app-credentials"

Multiple GitHub Apps

kubectl create secret generic app1-credentials \
  --from-file=github-app-private-key=/path/to/app1_key.pem
kubectl create secret generic app2-credentials \
  --from-file=github-app-private-key=/path/to/app2_key.pem

helm install github-sts oci://ghcr.io/depthmark/charts/github-sts \
  --set github.apps.app1.appId="111" \
  --set github.apps.app1.existingSecret="app1-credentials" \
  --set github.apps.app2.appId="222" \
  --set github.apps.app2.existingSecret="app2-credentials"

Note: Each app's private key must be stored in an existing Kubernetes Secret. The app name is used in trust policy paths: {policy.basePath}/{appName}/{identity}.sts.yaml

App Pools (several GitHub Apps behind one name)

An entry under github.apps can be backed by a pool of GitHub Apps instead of one. Each instance has its own primary rate-limit budget, so the exchange ceiling for that app name scales with the pool, and the server fails over to another instance when the one it tried is rate-limited or unreachable. Callers keep sending the single logical name in app=.

github:
  apps:
    checkout:
      orgPolicyRepo: .github
      instances:
        - name: checkout-1          # optional; defaults to appId
          appId: "111111"
          existingSecret: checkout-1-credentials
        - name: checkout-2
          appId: "222222"
          existingSecret: checkout-2-credentials
      rotation:
        strategy: round_robin       # round_robin (default) | rate_limit_aware
        maxAttempts: 2              # bound failover fan-out per request

instances and appId are mutually exclusive on one entry; the chart fails the render if both are set. Each instance's key is projected under /etc/github-sts/apps/{app}/{appId}/{key}, so instances may reuse a key name or share a Secret.

Pool support needs github-sts 0.1.1 or later, which is what this chart's appVersion pins. An older image rejects instances: outright instead of falling back to the flat form. The config decoder runs with known-fields checking, so the pod CrashLoopBackOffs with field instances not found in type config.AppConfig. Only an image.tag or image.digest override below the appVersion reaches that state.

Every instance in a pool must be installed with identical permissions and repository access. The server treats members as interchangeable and does not verify that they are, so a mismatched instance shows up as intermittent 422 responses. Alert on githubsts_app_pool_exhausted_total, which increments when every instance in a pool failed one request.

App keys in Azure Key Vault

signer replaces existingSecret on an entry or a pool instance. The App private key then stays in Azure Key Vault: github-sts sends the vault a digest and receives the signature of the App JWT, and the chart mounts no key into the pod. Each signer names the cloud identity that signs with its key, defined once under cloudIdentities:

cloudIdentities:
  vault-one:
    azure:
      clientId: 00000000-0000-0000-0000-000000000001
      tenantId: 00000000-0000-0000-0000-000000000003
  vault-two:
    azure:
      clientId: 00000000-0000-0000-0000-000000000002
      tenantId: 00000000-0000-0000-0000-000000000003
github:
  apps:
    checkout:
      appId: "111111"
      signer:
        cloudIdentity: vault-one
        keyId: https://vault-one.vault.azure.net/keys/github-app-checkout
    settings:
      appId: "222222"
      signer:
        cloudIdentity: vault-two
        keyId: https://vault-two.vault.azure.net/keys/github-app-settings

Each entry is a user-assigned managed identity; clientId and tenantId are both required, and the identity signs only in vaults of its own tenant. github-sts authenticates by workload identity only: the chart projects one ServiceAccount token for api://AzureADTokenExchange and sets AZURE_FEDERATED_TOKEN_FILE, and Microsoft Entra ID exchanges that token for whichever identity a key names. No Azure secret exists and no webhook is needed. Each identity needs:

  1. A federated credential with this cluster's service account issuer, the subject system:serviceaccount:<namespace>:<service account> and the audience api://AzureADTokenExchange. helm install prints the subject.
  2. The sign permission on its own keys and nothing else.

The chart fails the render on a signer that names an undefined identity, and on an identity no signer names. Separate identities split grants and audit logs per vault, not Apps inside one release: the pod can sign as every identity that trusts its ServiceAccount, so run separate releases to isolate Apps from each other.

A release uses one kind of key source: every instance of every app has a signer, or every one has an existingSecret. The chart refuses a mix, as the server does at startup. signer needs a github-sts image that knows cloud_identities, 0.1.3 or later. The chart refuses to render a signer on its default image while its appVersion is older; an explicit older image.tag or image.digest is rejected at startup with field signer not found in type config.AppConfig.

How It Works

  Workload                  github-sts                   GitHub
     │                          │                          │
     │  GET /sts/exchange       │                          │
     │  ?scope=org/repo         │                          │
     │  &app=my-app             │                          │
     │  &identity=ci            │                          │
     │  Authorization: Bearer   │                          │
     │─────────────────────────>│                          │
     │                          │  Validate OIDC sig/exp   │
     │                          │  Load trust policy       │
     │                          │  Evaluate claims         │
     │                          │  Request install token ──>
     │                          │<─────────────────────────│
     │<─────────────────────────│                          │
     │  { token, permissions }  │                          │

Trust Policies

Policies are fetched directly from GitHub repositories at {basePath}/{appName}/{identity}.sts.yaml.

Default path: .github/sts/{appName}/{identity}.sts.yaml

Example policy (.github/sts/default/ci.sts.yaml):

issuer: https://token.actions.githubusercontent.com
subject: repo:org/repo:ref:refs/heads/main
permissions:
  contents: read
  issues: write

See the upstream documentation for full policy schema and examples.

Enterprise Rego Bundles

Set bundles to configure signed OPA/Rego bundles. Bundles are evaluated after the YAML trust policy allows and before GitHub token minting, and a deny wins across all applicable bundles.

bundleEnforcement sets the top-level bundle_enforcement value the server requires; the chart always renders it, defaulting to optional. Set it to required where a bundle is a control rather than a convenience: under optional an empty bundles list silently drops the Rego layer, while required refuses to start without one.

bundles:
  - name: enterprise-baseline
    apps: []
    ref: oci://ghcr.io/example/github-sts-policy@sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
    expected_policy_revision: "42"
    poll_interval: 5m
    max_staleness: 10m
    fail_mode: closed
    registry:
      auth:
        mode: basic
        username: robot$github-sts
        password_file: /var/run/secrets/bundle/registry-password
    cosign:
      certificate_identity_regexp: '^https://github\.com/example/github-sts-policy/\.github/workflows/release\.yml@refs/heads/main$'
      certificate_oidc_issuer: https://token.actions.githubusercontent.com

Registry auth is separate from cosign verification. For registry.auth.password_file, local file bundle refs, or cosign.public_key_ref, mount files with extraVolumes and extraVolumeMounts and point password_file, ref, or public_key_ref at the mounted path.

Required mode constrains the entries further, including digest pinning and the signed revision each entry must declare. See the upstream configuration reference for those rules.

GitHub Actions Usage

jobs:
  deploy:
    runs-on: ubuntu-latest
    permissions:
      id-token: write
    steps:
      - name: Get scoped GitHub token
        id: sts
        run: |
          OIDC_TOKEN=$(curl -sH "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
            "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=github-sts" | jq -r '.value')

          GITHUB_TOKEN=$(curl -sf \
            -H "Authorization: Bearer $OIDC_TOKEN" \
            "${{ vars.STS_URL }}/sts/exchange?scope=${{ github.repository }}&app=default&identity=ci" \
            | jq -r '.token')

          echo "::add-mask::$GITHUB_TOKEN"
          echo "token=$GITHUB_TOKEN" >> $GITHUB_OUTPUT

      - name: Use scoped token
        env:
          GITHUB_TOKEN: ${{ steps.sts.outputs.token }}
        run: gh issue list

Values

KeyTypeDefaultDescription
affinityobject{}Affinity rules
audit.bufferSizeint1024Channel buffer size for async audit writes
audit.fileEnabledbooltrueEnable audit file logging
audit.filePathstring"/var/log/github-sts/audit.json"Path to audit log file inside the container
autoscaling.behaviorobject{}HPA scaling behavior (autoscaling/v2 behavior block). Tune scale-up and scale-down stabilization windows / policies to add backpressure when a webhook flood would otherwise saturate the existing replicas. Empty by default; the example below is a conservative starting point.
autoscaling.enabledboolfalseEnable Horizontal Pod Autoscaler
autoscaling.maxReplicasint10Maximum number of replicas
autoscaling.minReplicasint2Minimum number of replicas
autoscaling.targetCPUUtilizationPercentageint80Target CPU utilization percentage
bundleEnforcementstring"optional"Bundle enforcement mode: optional or required. The server requires a valid value here and refuses to start without one, so the chart always renders it. optional evaluates whatever bundles lists and falls back to YAML-only trust-policy authorization when the list is empty. required turns the Rego layer into a startup precondition: at least one bundle must be configured, every entry needs an expected_policy_revision and an oci:// ref pinned to @sha256:<64 hex>, allow_mutable_ref and cosign.skip_verification must stay false, and a bundle that applies to every app (apps: []) must use fail_mode: closed.
bundleslist[]Signed Rego/OPA bundles evaluated after the YAML trust policy allows and before a GitHub installation token is minted. Entries are passed through to the server's top-level bundles: config without validation or renaming, so use the server's snake_case field names. For a local file ref, registry.auth.password_file, or cosign.public_key_ref, mount the file with extraVolumes and extraVolumeMounts and point the field at the mounted path.
cloudIdentitiesobject{}Cloud identities map, by name.
commonLabelsobject{}Labels to add to all deployed objects
endpointAuth.existingSecretstring""Existing Secret holding the tokens. When empty and a token is set below, the chart creates a Secret of its own. Point this at your own Secret when the token comes from an external secret manager. The chart then renders no Secret and only references it, and the two key names below declare which tokens that Secret actually holds.
endpointAuth.healthKeystring"health-auth-token"Key inside the Secret holding the /health bearer token. Clear it to declare that existingSecret holds no health token, which leaves /health unauthenticated and lets the liveness probe stay on httpGet.
endpointAuth.healthTokenstring""Bearer token required on `GET

Deploy github-sts with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has github-sts on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartgithub-sts is pinned at v0.1.3 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply