token

package
v0.0.0-...-39c9a9b Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyToken empty token
	ErrEmptyToken = errors.New("token: empty token")
)

Functions

func GenerateToken

func GenerateToken(payload M) (string, error)

GenerateToken generate a token with given payload

func Init

func Init(c *Config) error

Init init config

Types

type Config

type Config struct {
	Secret string
	// LookupMethod methods to lookup token
	// Here are support 3 methods:
	// ["query-<param>", "header-<key>", "cookie-<key>"]
	// eg: ["query-token", "header-token", "cookie-token"]
	// Will start looking up the token from the beginning of the array, and stop until it is found
	LookupMethod []string
	// contains filtered or unexported fields
}

Config jwt config

func (*Config) Init

func (c *Config) Init() error

Init -

type M

type M map[string]interface{}

M payload in jwt

func Parse

func Parse(tokenString string, secret string) (payload M, err error)

Parse validates the token with the specialized secret,

func ParseFromRequest

func ParseFromRequest(r *http.Request) (payload M, err error)

ParseFromRequest parse token from request

Jump to

Keyboard shortcuts

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