validator

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2019 License: Apache-2.0 Imports: 20 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenExpired    = errors.New("token expired")
	ErrInvalidDuration = errors.New("duration higher than token expiry")
)

ErrTokenExpired - error token expired

Functions

func GetDefaultExpiration

func GetDefaultExpiration(dsecs string) (time.Duration, error)

GetDefaultExpiration - returns the expiration seconds expected.

Types

type ID

type ID string

ID - holds identification name authentication validator target.

type JWKS

type JWKS struct {
	Keys []*JWKS `json:"keys,omitempty"`

	Kty string `json:"kty"`
	Use string `json:"use,omitempty"`
	Kid string `json:"kid,omitempty"`
	Alg string `json:"alg,omitempty"`

	Crv string `json:"crv,omitempty"`
	X   string `json:"x,omitempty"`
	Y   string `json:"y,omitempty"`
	D   string `json:"d,omitempty"`
	N   string `json:"n,omitempty"`
	E   string `json:"e,omitempty"`
	K   string `json:"k,omitempty"`
}

JWKS - https://tools.ietf.org/html/rfc7517

func (*JWKS) DecodePublicKey

func (key *JWKS) DecodePublicKey() (crypto.PublicKey, error)

DecodePublicKey - decodes JSON Web Key (JWK) as public key

type JWKSArgs

type JWKSArgs struct {
	URL *xnet.URL `json:"url"`
	// contains filtered or unexported fields
}

JWKSArgs - RSA authentication target arguments

func (*JWKSArgs) PopulatePublicKey

func (r *JWKSArgs) PopulatePublicKey() error

PopulatePublicKey - populates a new publickey from the JWKS URL.

func (*JWKSArgs) UnmarshalJSON

func (r *JWKSArgs) UnmarshalJSON(data []byte) error

UnmarshalJSON - decodes JSON data.

func (*JWKSArgs) Validate

func (r *JWKSArgs) Validate() error

Validate JWT authentication target arguments

type JWT

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

JWT - rs client grants provider details.

func NewJWT

func NewJWT(args JWKSArgs) *JWT

NewJWT - initialize new jwt authenticator.

func (*JWT) ID

func (p *JWT) ID() ID

ID returns the provider name and authentication type.

func (*JWT) Validate

func (p *JWT) Validate(token, dsecs string) (map[string]interface{}, error)

Validate - validates the access token.

type Validator

type Validator interface {
	// Validate is a custom validator function for this provider,
	// each validation is authenticationType or provider specific.
	Validate(token string, duration string) (map[string]interface{}, error)

	// ID returns provider name of this provider.
	ID() ID
}

Validator interface describes basic implementation requirements of various authentication providers.

type Validators

type Validators struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Validators - holds list of providers indexed by provider id.

func NewValidators

func NewValidators() *Validators

NewValidators - creates Validators.

func (*Validators) Add

func (list *Validators) Add(provider Validator) error

Add - adds unique provider to provider list.

func (*Validators) Get

func (list *Validators) Get(id ID) (p Validator, err error)

Get - returns the provider for the given providerID, if not found returns an error.

func (*Validators) List

func (list *Validators) List() []ID

List - returns available provider IDs.

Jump to

Keyboard shortcuts

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