oidcverify

package
v0.19.1287 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package oidcverify verifies OIDC ID tokens against admin-configured issuers.

The issuer a token is verified against always comes from stored configuration, never from the token itself. Discovery and JWKS fetches go through a transport that refuses to reach local or internal networks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnverifiedIssuer

func UnverifiedIssuer(rawToken string) (string, error)

UnverifiedIssuer extracts the iss claim without checking the signature. It exists to select stored configuration; authorization must use Verify. Only compact JWTs are accepted so a flattened JWS cannot steer discovery.

func ValidateIssuerURL

func ValidateIssuerURL(ctx context.Context, raw string, allowInsecure bool) error

ValidateIssuerURL checks that raw is safe to store as a trust policy issuer: an https URL with a host and no credentials, query, or fragment, that does not address a private or internal network. allowInsecure permits http and local/internal hosts, for tests and local development.

Types

type Verifier

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

Verifier verifies OIDC ID tokens.

Providers are cached per issuer: oidc.Provider owns a key set that caches JWKS and refreshes on an unknown kid, so constructing one per request would repeat discovery and throw away rotated keys.

func NewVerifier

func NewVerifier(allowInsecure func() bool) *Verifier

NewVerifier returns a verifier. allowInsecure permits issuers that are not on the public internet, for tests and local development.

func (*Verifier) Discover

func (v *Verifier) Discover(ctx context.Context, issuer string) error

Discover confirms the issuer serves a discovery document whose issuer matches, and caches the provider. Call it when an issuer is configured so a typo fails the configuration request instead of the first token exchange.

func (*Verifier) Verify

func (v *Verifier) Verify(ctx context.Context, rawToken, issuer, audience string) (map[string]any, error)

Verify checks the token's signature, issuer, audience, and time claims against the given issuer and audience, and returns the verified claims.

issuer and audience must come from stored configuration. The unverified iss claim is only safe for choosing which configuration to load.

Jump to

Keyboard shortcuts

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