jwk

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultClientConfig is the default Client Config.
	DefaultClientConfig = ClientConfig{
		CacheTimeout:   defaultCacheTimeout,
		RequestTimeout: defaultRequestTimeout,
	}
)

Functions

This section is empty.

Types

type Client

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

Client fetch keys from a JSON Web Key set endpoint.

func NewClient

func NewClient(jwksEndpoint string, options ...Option) (*Client, error)

NewClient returns a new JWKS client.

func (*Client) ForceRefresh

func (client *Client) ForceRefresh()

ForceRefresh refresh cache while called. the call is ignored if client is stopped or not started yet.

func (*Client) KeySet

func (client *Client) KeySet() *JSONWebKeySet

KeySet returns the cached JSONWebKeySet.

func (*Client) PreLoad

func (client *Client) PreLoad(kid string, key *rsa.PublicKey)

PreLoad `kid` and `rsa.PublicKey` pair into client.

func (*Client) Start

func (client *Client) Start() error

Start to fetch and cache JWKS.

func (*Client) Stop

func (client *Client) Stop()

Stop to update cache periodically.

type ClientConfig

type ClientConfig struct {
	DisableStrictTLS bool
	EnableDebug      bool
	AppendCACert     bool
	CACertPath       string
	ServerHostName   string

	CacheTimeout   time.Duration
	RequestTimeout time.Duration
	Headers        map[string]string
	// contains filtered or unexported fields
}

ClientConfig used to init JWKS client.

type JSONWebKey

type JSONWebKey struct {
	Key          interface{}
	Certificates []*x509.Certificate
	KeyID        string
	Algorithm    string
	Use          string
}

JSONWebKey represents a RSA public key in JWK format.

func (JSONWebKey) MarshalJSON

func (key JSONWebKey) MarshalJSON() ([]byte, error)

MarshalJSON returns JSON representation of the given key.

func (*JSONWebKey) Thumbprint

func (key *JSONWebKey) Thumbprint(hash crypto.Hash) ([]byte, error)

Thumbprint returns thumbprint of the given key using the provided hash.

func (*JSONWebKey) UnmarshalJSON

func (key *JSONWebKey) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON returns the key from JSON representation.

func (*JSONWebKey) Valid

func (key *JSONWebKey) Valid() bool

Valid checks the given key.

type JSONWebKeySet

type JSONWebKeySet struct {
	Keys []JSONWebKey `json:"keys"`
}

JSONWebKeySet represents a JWK Set object.

func (*JSONWebKeySet) Key

func (set *JSONWebKeySet) Key(kid string) []JSONWebKey

Key returns keys by key ID.

type Option

type Option = func(*ClientConfig) error

Option applies config to Client Config.

Jump to

Keyboard shortcuts

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