jwks

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package jwks implements a JWKS cache with disk fallback and background refresh.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache owns the live keyfunc and atomically swaps it on each successful refresh.

func New

func New(ctx context.Context, log logger.AppLogger, cfg Config) (*Cache, error)

New loads the cache (wire-first, disk-fallback) and starts the refresh loop.

func (*Cache) Keyfunc

func (c *Cache) Keyfunc(tok *jwt.Token) (any, error)

Keyfunc adapts the cache to the jwt.Keyfunc signature so callers can pass it straight into jwt.ParseWithClaims. Safe to call concurrently with the refresh loop; uses an atomic load.

type Config

type Config struct {
	JWKSURL  string        //  URL of the JWKS endpoint (e.g. https://auth.optimum.com/auth/v1/.well-known/jwks.json)
	DiskPath string        // local filesystem path for the disk cache (e.g. /var/cache/jwks.json)
	Refresh  time.Duration // interval for background refreshes (e.g. 15m)
}

Config holds Cache construction params.

Jump to

Keyboard shortcuts

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