jwkscache

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: Apache-2.0 Imports: 18 Imported by: 2

Documentation

Overview

Package jwkscache contains utils to manage a cache of a JWK Set (via jwk.Set). It supports retrieving a JWKS from:

- A path on the local disk. This is watched with fsnotify to automatically reload the JWKS when the file changes on disk. - A HTTP(S) URL. This is automatically refreshed if a caller requests a key that isn't in the cached set. - A JWKS passed during initialization, optionally base64-encoded.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JWKSCache

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

JWKSCache is a cache of JWKS objects. It fetches a JWKS object from a file on disk, a URL, or from a value passed as-is.

func NewJWKSCache

func NewJWKSCache(location string, logger logger.Logger) *JWKSCache

NewJWKSCache creates a new JWKSCache object.

func (*JWKSCache) KeySet

func (c *JWKSCache) KeySet() jwk.Set

KeySet returns the jwk.Set with the current keys.

func (*JWKSCache) SetCACertificate added in v0.13.0

func (c *JWKSCache) SetCACertificate(caCertificate string)

SetCACertificate sets the CA certificate to trust. Can be a path to a local file or an actual, PEM-encoded certificate

func (*JWKSCache) SetHTTPClient

func (c *JWKSCache) SetHTTPClient(client *http.Client)

SetHTTPClient sets the HTTP client object to use.

func (*JWKSCache) SetMinRefreshInterval

func (c *JWKSCache) SetMinRefreshInterval(minRefreshInterval time.Duration)

SetMinRefreshInterval sets the minimum interval for refreshing a JWKS from a URL if a key is not found in the cache.

func (*JWKSCache) SetRequestTimeout

func (c *JWKSCache) SetRequestTimeout(requestTimeout time.Duration)

SetRequestTimeout sets the timeout for network requests.

func (*JWKSCache) Start

func (c *JWKSCache) Start(ctx context.Context) error

Start the JWKS cache. This method blocks until the context is canceled.

func (*JWKSCache) WaitForCacheReady

func (c *JWKSCache) WaitForCacheReady(ctx context.Context) error

WaitForCacheReady pauses until the cache is ready (the initial JWKS has been fetched) or the passed ctx is canceled. It will return the initialization error.

Jump to

Keyboard shortcuts

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