Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAlgorithm = errors.New("token algorithm does not match its key")
Error of a token whose signing algorithm differs from the one its key is published for
var ErrKeyNotFound = errors.New("jwk set has no matching signing key")
Error of a key lookup the JWK set has no signing key for, wrapped with the key id asked for
var ErrNoKeys = errors.New("jwk set has no usable signing keys")
Error of a JWK set that holds no key able to verify signatures
Functions ¶
This section is empty.
Types ¶
type FetchError ¶
Failed fetch of a JWK set: its address, the HTTP status when the server answered with an error status, else the transport or decoding error
func (*FetchError) Error ¶
func (e *FetchError) Error() string
The address and what went wrong, as in fetch jwk set https://example.com/keys: 503 Service Unavailable
func (*FetchError) Unwrap ¶
func (e *FetchError) Unwrap() error
Transport or decoding error of the fetch, nil for an error status
type JWKClient ¶
type JWKClient struct {
URL string
Header http.Header
HTTP *http.Client
Timeout time.Duration
Lifespan time.Duration
MinRefresh time.Duration
// contains filtered or unexported fields
}
Cached view of a JWK set endpoint, safe for concurrent use: Header is sent with each fetch, HTTP fetches (http.DefaultClient when nil), Timeout bounds one fetch (30 seconds when zero), Lifespan is how long a fetched set serves before a lookup renews it in the background (5 minutes when zero), MinRefresh is the shortest gap after which an unknown key id or a failed refresh fetches again (30 seconds when zero); set the fields before the first lookup
func NewJWKClient ¶
Client of the JWK set at url with the default timeout, lifespan and refresh gap
func (*JWKClient) Key ¶
Signing key with key id kid, or the only signing key of the set when kid is empty and the set has exactly one; the cached set answers at once, past its lifespan too while a background fetch renews it or after that fetch failed, and an unknown kid waits for a fetch of the set once MinRefresh has passed since the last one