Documentation
¶
Overview ¶
Package githuboidc verifies GitHub Actions OIDC tokens so a CI workflow can authenticate to the API without a shared secret. It is a thin wrapper over go-oidc: the discovery document and signing keys (JWKS) come from GitHub's OIDC provider, and every token is checked for a valid RS256 signature, the expected issuer and audience, and expiry.
This is workload identity — the caller is a GitHub Actions job, not a human. It is deliberately independent of any future interactive SSO login.
Index ¶
Constants ¶
const DefaultIssuer = "https://token.actions.githubusercontent.com"
DefaultIssuer is GitHub's hosted Actions OIDC provider. GitHub Enterprise Server uses a different issuer; override it via NewVerifier.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Claims ¶
type Claims struct {
// Repository is "owner/name" of the repo whose workflow minted the token.
Repository string `json:"repository"`
// RepositoryOwner is the "owner" half of Repository.
RepositoryOwner string `json:"repository_owner"`
// Ref is the git ref the workflow ran for, e.g. "refs/heads/main".
Ref string `json:"ref"`
// SHA is the commit the workflow ran for.
SHA string `json:"sha"`
// Workflow is the name of the workflow that ran.
Workflow string `json:"workflow"`
// Actor is the user who triggered the run.
Actor string `json:"actor"`
// Subject is the token's "sub", e.g. "repo:owner/name:ref:refs/heads/main".
Subject string `json:"sub"`
}
Claims are the GitHub Actions OIDC claims the authorizer needs. GitHub sets many more (run_id, job_workflow_ref, environment, …); we decode only the ones used for authorization and logging.
type Verifier ¶
type Verifier struct {
// contains filtered or unexported fields
}
Verifier verifies GitHub Actions OIDC tokens for a fixed issuer and audience. The zero value is not usable; construct one with NewVerifier.
func NewVerifier ¶
NewVerifier returns a Verifier that accepts tokens from issuer whose "aud" contains audience. issuer defaults to DefaultIssuer when empty. The provider's discovery document and keys are fetched lazily on first Verify, so constructing a Verifier never blocks or fails on network — a starting server doesn't depend on GitHub being reachable at boot.