jwt

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package jwt provides a basic implementation of JSON Web Token as described in RFC 7519.

Index

Constants

View Source
const (
	// HMAC Signer
	HS256 = "HS256"
	HS384 = "HS384"
	HS512 = "HS512"

	// RSA-PKCS family
	RS256 = "RS256"
	RS384 = "RS384"
	RS512 = "RS512"

	// RSA-PSS family
	PS256 = "PS256"
	PS384 = "PS384"
	PS512 = "PS512"

	// ECDSA Signer
	ES256 = "ES256"
	ES384 = "ES384"
	ES512 = "ES512"

	// None
	None = "none"
)
View Source
const JWT = "jwt"

Variables

View Source
var (
	//ErrSignature is returned when the signature of token does not match the
	//expected signature generated with the secret key
	ErrSignature = errors.New("bad signature")

	//ErrMalformed is returned when the token does not have the expected format
	//as described in the RFC.
	ErrMalformed = errors.New("malformed token")

	//ErrInvalid is returned when the token hasn't the good issuer or when it has
	//expired or when the issue at is after the expiration time. ErrInvalid is
	//also returned when the payload can not be unmarshaled from the token.
	ErrInvalid = errors.New("invalid token")
)

Common errors type

Functions

This section is empty.

Types

type Alg

type Alg string

type Option

type Option func(*Signer) error

func WithECDSA

func WithECDSA() Option

func WithIssuer

func WithIssuer(issuer string) Option

func WithPKCS

func WithPKCS(size int) Option

func WithSecret

func WithSecret(secret []byte, alg string) Option

func WithTime

func WithTime(ttl, ttw time.Duration) Option

type Signer

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

func New

func New(options ...Option) (Signer, error)

func (Signer) Sign

func (s Signer) Sign(v interface{}) (string, error)

func (Signer) Verify

func (s Signer) Verify(token string, v interface{}) error

Jump to

Keyboard shortcuts

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