Documentation ¶
Index ¶
- Variables
- type Cache
- type JWK
- type LRUCache
- func (lc *LRUCache) Add(_ context.Context, key *JWK) error
- func (lc *LRUCache) Contains(_ context.Context, kid string) (bool, error)
- func (lc *LRUCache) Get(_ context.Context, kid string) (*JWK, error)
- func (lc *LRUCache) Len(_ context.Context) (int, error)
- func (lc *LRUCache) Purge(_ context.Context) error
- func (lc *LRUCache) Remove(_ context.Context, kid string) error
- type Manager
- type Option
- type TTLCache
- func (tc *TTLCache) Add(_ context.Context, key *JWK) error
- func (tc *TTLCache) Contains(_ context.Context, kid string) (bool, error)
- func (tc *TTLCache) Get(_ context.Context, kid string) (*JWK, error)
- func (tc *TTLCache) Len(_ context.Context) (int, error)
- func (tc *TTLCache) Purge(_ context.Context) error
- func (tc *TTLCache) Remove(_ context.Context, kid string) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrEmptyKeyID raises when input kid is empty. ErrEmptyKeyID = errors.New("cache: empty kid") // ErrCacheNotFound raises when cache value not found. ErrCacheNotFound = errors.New("cache: value not found") // ErrInvalidValue raises when type conversion to JWK has been failed. ErrInvalidValue = errors.New("cache: invalid value") )
View Source
var ( // ErrConnectionFailed raises when JWKS endpoint cannot be reached. ErrConnectionFailed = errors.New("jwks: connection failed") // ErrInvalidURL raises when input url has invalid format. ErrInvalidURL = errors.New("jwks: invalid url value or format") // ErrKeyIDNotProvided raises when input kid is not present. ErrKeyIDNotProvided = errors.New("jwks: kid is not provided") // ErrPublicKeyNotFound raises when no public key is found. ErrPublicKeyNotFound = errors.New("jwks: public key not found") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { Add(ctx context.Context, key *JWK) error Get(ctx context.Context, kid string) (*JWK, error) Remove(ctx context.Context, kid string) error Contains(ctx context.Context, kid string) (bool, error) Len(ctx context.Context) (int, error) Purge(ctx context.Context) error }
Cache works with cache layer.
type LRUCache ¶ added in v0.0.3
type LRUCache struct {
// contains filtered or unexported fields
}
func NewLRUCache ¶ added in v0.0.2
NewLRUCache returns a new instance of lru cache.
type Manager ¶
type Manager interface { FetchKey(ctx context.Context, kid string) (*JWK, error) CacheSize(ctx context.Context) (int, error) }
Manager fetches and returns JWK from public source.
type Option ¶
type Option func(m *manager)
Option is used for configuring key manager.
func WithHTTPClient ¶
WithHTTPClient sets custom http client.
func WithLogger ¶
WithLogger sets custom logger. Default log level is `disabled`.
func WithLookup ¶
WithLookup defines cache lookup option. Default is `true`.
func WithMaxRetries ¶
WithMaxRetries defines max retries count if request has been failed. Default is `5`.
Click to show internal directories.
Click to hide internal directories.