Federated OIDC Authentication
Terrakube can trust short-lived JWTs issued by an external OpenID Connect provider. The external token is sent directly as the Bearer token; there is no separate token-exchange endpoint and no Terrakube Personal Access Token (PAT) needs to be stored by the workload.
Terrakube verifies the token signature and standard lifetime and issuer claims using the provider's OIDC discovery metadata. It then requires the configured audience and every configured claim condition to match. A matching credential maps the workload to an existing Terrakube team, whose permissions continue to control the resources and operations the workload can use.
Configure Terrakube
Create a Terrakube team for the workload and grant only the required organization, workspace, module, provider, or job permissions.
Open Organization settings → Security → Federated Credentials and create a credential.
Set Terrakube team name to the exact name of the team from step 1.
Set the issuer and audience expected in the workload token.
Add at least one claim condition that identifies the repository or Kubernetes ServiceAccount.
OIDC discovery and the provider's JWKS endpoint must be reachable from both the Terrakube API and, when the private registry is used, the Terrakube registry service. Claim matching is exact; wildcard values are not supported.
Treat issuer, audience, and claim conditions as an authorization boundary. Use narrow conditions and grant the mapped Terrakube team only the permissions required by the workload.
GitHub Actions
Use these credential values for GitHub-hosted Actions:
Issuer URL
https://token.actions.githubusercontent.com
Audience
terrakube, or another value chosen for this Terrakube deployment
Recommended claim
repository = OWNER/REPOSITORY
Add narrower conditions such as ref or environment when only a particular branch or protected environment should have access. The workflow must explicitly request id-token: write, request the same audience configured in Terrakube, and send the returned JWT to the API:
The OIDC token is scoped to one job and expires automatically. Do not write it to logs or persist it as an artifact.
Kubernetes
The Kubernetes ServiceAccount issuer must expose standards-compliant OIDC discovery and JWKS metadata at the configured issuer URL. Create a credential using:
Issuer URL
The cluster's configured ServiceAccount issuer
Audience
terrakube
Recommended claim
sub = system:serviceaccount:automation:terrakube-client
Project a short-lived, audience-bound ServiceAccount token into the Pod instead of using the default API-server token:
The kubelet rotates projected tokens. Long-running clients must read the token file again before each request, or on a short interval, instead of caching its initial contents.
Troubleshooting
401 Unauthorized: verify the issuer URL exactly matches the token'siss, the configured audience is present inaud, discovery and JWKS are reachable, and the token has not expired.403 Forbiddenor an empty JSON response: verify every claim condition and confirm the credential name exactly matches a Terrakube team with access to the requested resource.Decode a token payload only in a secure local environment. The payload is useful for inspecting
iss,aud, and provider-specific claims, but decoding does not verify the signature.
Last updated
Was this helpful?