githuboidc

package
v0.31.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2026 License: GPL-3.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func NewVerifier(issuer, audience string) *Verifier

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.

func (*Verifier) Verify

func (v *Verifier) Verify(ctx context.Context, rawToken string) (Claims, error)

Verify checks rawToken's signature, issuer, audience, and expiry, returning its GitHub Actions claims. An invalid, expired, wrong-audience, or wrong-issuer token is an error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL