jwt

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: MIT Imports: 10 Imported by: 0

README

SMARTY DISCLAIMER: Subject to the terms of the associated license agreement, this software is freely available for your use. This software is FREE, AS IN PUPPIES, and is a gift. Enjoy your new responsibility. This means that while we may consider enhancement requests, we may or may not choose to entertain requests at our sole and absolute discretion.

smarty-jwt

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SegmentCountErr            = errors.New("a JWT must have three segments separated by period characters")
	MalformedHeaderErr         = errors.New("the header is malformed")
	MalformedHeaderContentErr  = errors.New("the header content is malformed")
	MalformedPayloadContentErr = errors.New("the payload content is malformed")
	MalformedSignatureErr      = errors.New("the signature is malformed")
	UnrecognizedSignatureErr   = errors.New("unrecognized signature")
	UnrecognizedAlgorithmErr   = errors.New("unrecognized algorithm")
)
View Source
var (
	TokenExpiredErr    = errors.New("the token is expired")
	InvalidAudienceErr = errors.New("the audience is invalid")
)

Functions

This section is empty.

Types

type Algorithm

type Algorithm interface {
	Name() string
	ComputeHash(value, secret []byte) []byte
}

type Decoder

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

func NewDecoder

func NewDecoder(options ...DecoderOption) *Decoder

func (Decoder) Decode

func (this Decoder) Decode(token string, claims interface{}) error

type DecoderOption

type DecoderOption func(*Decoder)

func WithDecodingAlgorithm

func WithDecodingAlgorithm(algorithm Algorithm) DecoderOption

func WithDecodingSecrets

func WithDecodingSecrets(callback func(id string) (secret []byte)) DecoderOption

func WithDecodingValidator

func WithDecodingValidator(validator Validator) DecoderOption

func WithNamedDecodingAlgorithms

func WithNamedDecodingAlgorithms(names ...string) DecoderOption

type DefaultValidator

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

func NewDefaultValidator

func NewDefaultValidator(audiences ...string) DefaultValidator

func (DefaultValidator) Validate

func (this DefaultValidator) Validate(claim interface{}) error

type Encoder

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

func NewEncoder

func NewEncoder(options ...EncoderOption) *Encoder

func (*Encoder) Encode

func (this *Encoder) Encode(claims interface{}) (token string, err error)

type EncoderOption

type EncoderOption func(encoder *Encoder)

func WithEncodingAlgorithm

func WithEncodingAlgorithm(algorithm Algorithm) EncoderOption

func WithEncodingSecret

func WithEncodingSecret(id string, secret []byte) EncoderOption

func WithNamedEncodingAlgorithm

func WithNamedEncodingAlgorithm(algorithm string) EncoderOption

type HS256

type HS256 struct{}

func (HS256) ComputeHash

func (this HS256) ComputeHash(value, secret []byte) []byte

func (HS256) Name

func (this HS256) Name() string

type HS384

type HS384 struct{}

func (HS384) ComputeHash

func (this HS384) ComputeHash(value, secret []byte) []byte

func (HS384) Name

func (this HS384) Name() string

type HS512

type HS512 struct{}

func (HS512) ComputeHash

func (this HS512) ComputeHash(value, secret []byte) []byte

func (HS512) Name

func (this HS512) Name() string

type NoAlgorithm

type NoAlgorithm struct{}

func (NoAlgorithm) ComputeHash

func (this NoAlgorithm) ComputeHash(value, secret []byte) []byte

func (NoAlgorithm) Name

func (this NoAlgorithm) Name() string

type StandardClaims

type StandardClaims struct {
	Expiration int64  `json:"exp,omitempty"`
	Audience   string `json:"aud,omitempty"`
}

func (StandardClaims) TokenAudience

func (this StandardClaims) TokenAudience() string

func (StandardClaims) TokenExpiration

func (this StandardClaims) TokenExpiration() time.Time

type TokenAudience

type TokenAudience interface {
	TokenAudience() string
}

type TokenExpiration

type TokenExpiration interface {
	TokenExpiration() time.Time
}

type Validator

type Validator interface {
	Validate(claims interface{}) error
}

Jump to

Keyboard shortcuts

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