jwks

package module
v0.0.0-...-55a3583 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2019 License: MIT Imports: 8 Imported by: 0

README

go-jwks

(Another) JWKS client for go

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrKidNotFound = errors.New("kid was not found in the jwks")

ErrKidNotFound kid was not found

Functions

func KeyFunc

func KeyFunc(jwks *JSONWebKeySet) func(token *jwt.Token) (interface{}, error)

KeyFunc gets the verify key from the keyset

Types

type Client

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

Client fetches a JWKS from specified endpoint

func NewClient

func NewClient(endpoint string, options *ClientOptions) *Client

NewClient creates a new JWKS client

func (*Client) GetSigningKey

func (c *Client) GetSigningKey(kid string) (*JSONWebKey, error)

GetSigningKey gets the verification key

func (*Client) IsValid

func (c *Client) IsValid(tokenString string) (bool, *jwt.Token, error)

IsValid checks if token is valid with recheck

func (*Client) KeySet

func (c *Client) KeySet() *JSONWebKeySet

KeySet returns the entire jwks

func (*Client) Keys

func (c *Client) Keys() []JSONWebKey

Keys returns the jwk keys

func (*Client) Parse

func (c *Client) Parse(tokenString string) (*jwt.Token, error)

Parse parses a jwt using the current JWKS

func (*Client) Start

func (c *Client) Start() error

Start starts the client polling the jwks endpoint

func (*Client) Stop

func (c *Client) Stop()

Stop stops the jwks refresh

type ClientOptions

type ClientOptions struct {
	Insecure       bool
	CacheTimeout   *time.Duration
	RequestTimeout *time.Duration
	Logger         Logger
}

ClientOptions options for client

type JSONWebKey

type JSONWebKey struct {
	Kid string   `json:"kid"`
	Kty string   `json:"kty"`
	Alg string   `json:"alg"`
	Use string   `json:"use"`
	X5c []string `json:"x5c"`
	X5t string   `json:"x5t"`
	N   string   `json:"n"`
	E   string   `json:"e"`
}

JSONWebKey a json web key

func GetSigningKey

func GetSigningKey(kid string, jwks *JSONWebKeySet) (*JSONWebKey, error)

GetSigningKey gets the signing key from the kid

type JSONWebKeySet

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

JSONWebKeySet a json web key set

type Logger

type Logger interface {
	Errorf(format string, args ...interface{})
	Debugf(format string, args ...interface{})
}

Logger a common logging interface

Jump to

Keyboard shortcuts

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