oidcjwt

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package oidcjwt verifies JWTs using OIDC discovery.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHTTPClient

func NewHTTPClient(issuer, certificateAuthorityFile, discoveryTokenFile string) (*http.Client, error)

NewHTTPClient returns a client for OIDC discovery and JWKS requests.

Types

type Claims

type Claims struct {
	// Claims from RFC7519
	Issuer     string
	Subject    string
	Audiences  []string
	Expiration time.Time
	NotBefore  time.Time
	IssuedAt   time.Time
	JTI        string

	KubernetesClaims
}

Claims contains standard JWT claims and, when present, Kubernetes ServiceAccount claims.

type KeyAndID

type KeyAndID struct {
	KeyID     string
	PublicKey crypto.PublicKey
}

KeyAndID wraps a crypto.PublicKey and its JWK key ID.

type KubernetesClaims

type KubernetesClaims struct {
	Namespace string

	ServiceAccountName string
	ServiceAccountUID  string
	PodName            string
	PodUID             string
	SecretName         string
	SecretUID          string
	NodeName           string
	NodeUID            string

	WarnAfter time.Time
}

KubernetesClaims contains claims added to Kubernetes ServiceAccount tokens.

type Verifier

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

Verifier verifies JWTs from one trusted OIDC issuer and caches its signing keys. Keys are refreshed periodically and, at a bounded rate, when a token names an unknown key ID.

func NewVerifier

func NewVerifier(issuer string, audiences []string, httpClient *http.Client) *Verifier

NewVerifier returns a verifier for issuer. A token is accepted when at least one of its audiences matches audiences.

func (*Verifier) Verify

func (v *Verifier) Verify(ctx context.Context, jwt string, now time.Time) (*Claims, error)

Verify verifies and extracts claims from a JWT.

Jump to

Keyboard shortcuts

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