jwks

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package jwks provides JWKS key resolution for JWT signature validation. It fetches RSA public keys from a JWKS endpoint, caches them by kid, and exposes a jwt.Keyfunc for use with the JWT middleware and auth clients.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseJWKS

func ParseJWKS(body []byte) (map[string]*rsa.PublicKey, error)

ParseJWKS parses a JWKS document into a kid-keyed map of RSA public keys.

Types

type Option

type Option func(*Resolver)

Option configures a Resolver.

func WithHTTPClient

func WithHTTPClient(c *http.Client) Option

WithHTTPClient sets the HTTP client used for JWKS fetches.

func WithTTL

func WithTTL(ttl time.Duration) Option

WithTTL sets the JWKS cache TTL (default 1h).

type Resolver

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

Resolver fetches and caches JWKS RSA keys by kid.

func New

func New(jwksURL string, opts ...Option) *Resolver

New creates a Resolver for a direct JWKS URL (e.g. https://host/.well-known/jwks.json).

func NewWithDiscovery

func NewWithDiscovery(issuer string, opts ...Option) *Resolver

NewWithDiscovery creates a Resolver that first fetches the OIDC discovery document to locate the jwks_uri. issuer is e.g. https://host/.

func (*Resolver) KeyFunc

func (r *Resolver) KeyFunc() jwt.Keyfunc

KeyFunc returns a jwt.Keyfunc that resolves the verification key by kid.

Jump to

Keyboard shortcuts

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