jwks

package
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 10 Imported by: 75

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CachingProvider

type CachingProvider struct {
	*Provider
	CacheTTL time.Duration
	// contains filtered or unexported fields
}

CachingProvider handles getting JWKS from the specified IssuerURL and caching them for CacheTTL time. It exposes KeyFunc which adheres to the keyFunc signature that the Validator requires. When the CacheTTL value has been reached, a JWKS refresh will be triggered in the background and the existing cached JWKS will be returned until the JWKS cache is updated, or if the request errors then it will be evicted from the cache.

func NewCachingProvider

func NewCachingProvider(issuerURL *url.URL, cacheTTL time.Duration, opts ...ProviderOption) *CachingProvider

NewCachingProvider builds and returns a new CachingProvider. If cacheTTL is zero then a default value of 1 minute will be used.

func (*CachingProvider) KeyFunc

func (c *CachingProvider) KeyFunc(ctx context.Context) (interface{}, error)

KeyFunc adheres to the keyFunc signature that the Validator requires. While it returns an interface to adhere to keyFunc, as long as the error is nil the type will be *jose.JSONWebKeySet.

type Provider

type Provider struct {
	IssuerURL     *url.URL // Required.
	CustomJWKSURI *url.URL // Optional.
	Client        *http.Client
}

Provider handles getting JWKS from the specified IssuerURL and exposes KeyFunc which adheres to the keyFunc signature that the Validator requires. Most likely you will want to use the CachingProvider as it handles getting and caching JWKS which can help reduce request time and potential rate limiting from your provider.

func NewProvider

func NewProvider(issuerURL *url.URL, opts ...ProviderOption) *Provider

NewProvider builds and returns a new *Provider.

func (*Provider) KeyFunc

func (p *Provider) KeyFunc(ctx context.Context) (interface{}, error)

KeyFunc adheres to the keyFunc signature that the Validator requires. While it returns an interface to adhere to keyFunc, as long as the error is nil the type will be *jose.JSONWebKeySet.

type ProviderOption

type ProviderOption func(*Provider)

ProviderOption is how options for the Provider are set up.

func WithCustomClient added in v2.1.0

func WithCustomClient(c *http.Client) ProviderOption

WithCustomClient will set a custom *http.Client on the *Provider

func WithCustomJWKSURI

func WithCustomJWKSURI(jwksURI *url.URL) ProviderOption

WithCustomJWKSURI will set a custom JWKS URI on the *Provider and call this directly inside the keyFunc in order to fetch the JWKS, skipping the oidc.GetWellKnownEndpointsFromIssuerURL call.

Jump to

Keyboard shortcuts

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