jwkset

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2017 License: BSD-3-Clause Imports: 10 Imported by: 2

README

go-jwkset

Build Status BSD License

go-jwkset is a library to fetch JSON Web Key Set on top of square/go-jose.v2 library. go-jwkset allows you to build cache-ware custom fetcher for JWKSet.

Built-in fetcher implementation

  • Plain HTTP
  • AWS S3

Versioning

This library follows Semantic Versions and we highly recommend to use some package manager such as dep or glide.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode added in v0.1.1

func Decode(r io.Reader) ([]jose.JSONWebKey, error)

Decode decodes the data with reading from r into JWKs.

Types

type Cacher

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

Cacher fetches JWKs via Cache if available.

func NewCacher

func NewCacher(defaultExpiration, cleanupInterval time.Duration, f Fetcher) *Cacher

NewCacher returns Cacher with initializing cache store.

func (*Cacher) FetchJWKs

func (c *Cacher) FetchJWKs(cacheKey string) (*Response, error)

FetchJWKs tries to retrieve JWKs from Cache. If the cache is not available, it will call Fetcher.FetchJWKs and cache the result for future request.

type Fetcher

type Fetcher interface {
	// FetchJWKs retrieves JWKSet from path.
	FetchJWKs(path string) (*Response, error)
}

Fetcher is an interface that represents JWKs fetcher.

type HTTPFetcher

type HTTPFetcher struct {
	Client *http.Client
}

HTTPFetcher fetches JWKs over HTTP.

func (*HTTPFetcher) FetchJWKs

func (f *HTTPFetcher) FetchJWKs(uri string) (*Response, error)

FetchJWKs implements Fetcher interface by using http.Client. FetchJWKs tries to retrieve JWKSet from uri.

type InMemoryFetcher added in v0.1.1

type InMemoryFetcher struct {
	RAWJWKs []byte
}

InMemoryFetcher fetches JWKs from its memory.

func (*InMemoryFetcher) FetchJWKs added in v0.1.1

func (f *InMemoryFetcher) FetchJWKs(_ string) (*Response, error)

FetchJWKs implements Fetcher interface by using internal JWKs.

type Response added in v0.1.1

type Response struct {
	Keys []jose.JSONWebKey

	TTL time.Duration // This would be used as TTL for caching.
}

Response represents a response of JWK Set. This contains a TTL (Time to Live) for caching purpose.

type S3Fetcher

type S3Fetcher struct {
	S3Svc s3iface.S3API
}

S3Fetcher fetches JWKs via S3.

func (*S3Fetcher) FetchJWKs

func (f *S3Fetcher) FetchJWKs(path string) (*Response, error)

FetchJWKs implements JWKsS3Fetcher by using S3. It tries to retrieve an S3 object from path. path must be in s3://<bucket>/<key>.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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