oidc

package
v1.0.0-alpha.13 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 17 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 oidc verifies CI OIDC ID tokens and reads a run's identity from them.

Only RS256 is accepted, the one algorithm both issuers' discovery documents list. docs/serve.md cites the source and retrieval date of every claim name, issuer URL and key set path below.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMalformed      = errors.New("oidc: malformed token")
	ErrAlgorithm      = errors.New("oidc: algorithm not accepted")
	ErrIssuer         = errors.New("oidc: unknown issuer")
	ErrKeyUnavailable = errors.New("oidc: signing key unavailable")
	ErrSignature      = errors.New("oidc: bad signature")
	ErrAudience       = errors.New("oidc: wrong audience")
	ErrExpired        = errors.New("oidc: token expired")
	ErrNotYetValid    = errors.New("oidc: token not yet valid")
	ErrClaims         = errors.New("oidc: run identity claims missing or invalid")
)

The refusals. A caller reports one answer to the sender and logs which.

Functions

This section is empty.

Types

type Identity

type Identity struct {
	Host         string
	Owner        string
	Repository   string
	RunID        string
	RunAttempt   string
	CommitSHA    string
	CommitIsHead bool
	Actor        string
	Event        string
	PullRequest  string
	// Environment is the GitHub deployment environment the job referenced,
	// empty when it referenced none. Its protection rules are the
	// repository's, so only a job they admitted carries it.
	Environment string
}

Identity is a run as the token states it. Repository is lower case, host and path, the form of the costroid/repo tag. PullRequest is empty unless the token itself names one.

CommitSHA is the commit the token verifies. It is the head of the ref only when CommitIsHead says so: on GitHub's pull_request event it is a merge commit, and on a GitLab merged results pipeline a temporary one.

type Issuer

type Issuer struct {
	Kind    Kind
	URL     string
	JWKSURL string
	// Host is the SCM host its repositories live on.
	Host string
}

Issuer is one trusted token issuer.

func GitHub

func GitHub() Issuer

GitHub is github.com's Actions issuer.

func GitLab

func GitLab(host string) Issuer

GitLab is a GitLab instance's CI issuer, given its host name.

func (Issuer) KeySetHost

func (i Issuer) KeySetHost() string

KeySetHost is the host the issuer's signing keys are read from, the one an egress allowlist must hold. GitHub's is not Host.

type Kind

type Kind int

Kind selects how an issuer's claims read.

const (
	GitHubActions Kind = iota + 1
	GitLabCI
)

The CI systems with a claim mapping.

type Verifier

type Verifier struct {
	// contains filtered or unexported fields
}

Verifier checks tokens against a set of issuers and one audience.

func NewVerifier

func NewVerifier(audience string, client *http.Client, now func() time.Time, issuers ...Issuer) *Verifier

NewVerifier returns a Verifier that reads key sets through client. A nil clock means time.Now.

func (*Verifier) Verify

func (v *Verifier) Verify(ctx context.Context, token string) (Identity, error)

Verify checks a token and returns the run it names.

Directories

Path Synopsis
Package oidctest is a stub OIDC issuer for tests: an RSA key, a JWKS endpoint and a signer.
Package oidctest is a stub OIDC issuer for tests: an RSA key, a JWKS endpoint and a signer.

Jump to

Keyboard shortcuts

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