jwt

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Issuer                          = "Anonymous"
	SigningKey                      = []byte("Please replace the default signing key")
	SigningMethod jwt.SigningMethod = jwt.SigningMethodHS256

	ErrCustomClaimsInValid = errors.New("custom claims invalid")
)

Functions

func GenerateJWTToken

func GenerateJWTToken(customClaims *CustomClaims) (string, error)

func GetCustomData

func GetCustomData(tokenStr string, signingKey ...string) (string, error)

func SetIssuer

func SetIssuer(issuer string)

func SetSigningMethod

func SetSigningMethod(method jwt.SigningMethod)

func VerifyJWTToken

func VerifyJWTToken(tokenStr string, signingKey ...string) (bool, error)

Types

type CustomClaims

type CustomClaims struct {
	SigningKey []byte
	Data       string `json:"data"` // any string, can be JSON marshal {"a":1}
	jwt.StandardClaims
}

func NewCustomClaims

func NewCustomClaims(data string, ttl time.Duration, signingKey ...string) *CustomClaims

NewCustomClaims custom request authorization

type CustomData

type CustomData string

custom data string

Jump to

Keyboard shortcuts

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