jwt

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrJWTExpired   = errors.New("Your JWT token has expired")
	ErrInvalidToken = errors.New("Your token is an invalid JWT token")
	ErrNoClaims     = errors.New("There are no claims in your token")
)

Functions

func Decode

func Decode(secret []byte, token []byte) (map[string]interface{}, error)

Decode validates and parses the given JWT token into a map

func DecodeEmbedded

func DecodeEmbedded(secret []byte, tokenBytes []byte, v interface{}) error

DecodeEmbedded validates and parses a JWT token into a struct. It expects the struct's payload to be attached to the key `claim` of the actual JWT claim. Note that the struct should have json tags

func DecodeStruct

func DecodeStruct(secret []byte, tokenBytes []byte, v interface{}) error

DecodeStruct validates and parses a JWT token into a struct.

func Encode

func Encode(secret []byte, t time.Duration, payload map[string]interface{}) (string, error)

Encodes generates and signs a JWT token for the given payload using the HMAC algorithm.

func EncodeEmbedded

func EncodeEmbedded(secret []byte, t time.Duration, v interface{}) (string, error)

EncodeEmbedded attaches the payload as an entry to the final claim using the key `claim` to prevent clashes with JWT field names.

func EncodeStruct

func EncodeStruct(secret []byte, t time.Duration, v interface{}) (string, error)

EncodeStruct generates a JWT token for the given struct using the HMAC algorithm.

Types

This section is empty.

Jump to

Keyboard shortcuts

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