jwtm

package
v0.0.0-...-296fbc6 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenInvalid = errors.New("token is invalid")

	ErrTokenExpired = errors.New("token is expired")

	ErrTokenMalformed = errors.New("token is malformed")

	ErrTokenNotValidYet = errors.New("token is not valid yet")

	ErrTokenUnverifiable = errors.New("token could not be verified because of signing problems")

	ErrTokenSignatureValidation = errors.New("signature validation failed")

	ErrCannotHandle = errors.New("cannot handle this problem")
)

Functions

This section is empty.

Types

type CookieOptions

type CookieOptions struct {
	Path    string    // optional
	Domain  string    // optional
	Expires time.Time // optional

	MaxAge   int
	Secure   bool
	HttpOnly bool
	SameSite http.SameSite
}

type HttpTokenExtractor

type HttpTokenExtractor func(c context.Context, req *http.Request) string

func MakeCookieTokenExtractor

func MakeCookieTokenExtractor(cookieName string) HttpTokenExtractor

func MakeHeaderTokenExtractor

func MakeHeaderTokenExtractor(headerName string, tokenType string) HttpTokenExtractor

type HttpTokenWriter

type HttpTokenWriter func(c context.Context, w http.ResponseWriter, token string) error

func MakeCookieTokenWriter

func MakeCookieTokenWriter(cookieName string, cookieOptions CookieOptions) HttpTokenWriter

func MakeHeaderTokenWriter

func MakeHeaderTokenWriter(headerName string, tokenType string) HttpTokenWriter

type Manager

type Manager interface {
	NewToken(claims jwt.Claims) (string, error)
	ParseAndVerify(token string, claims jwt.Claims) (jwt.Claims, error)
}

func NewManger

func NewManger(method jwt.SigningMethod, signingKey interface{}, verifyKey interface{}) Manager

Jump to

Keyboard shortcuts

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