token

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingHeader = errors.New("the length of the `Authorization` header is zero")
	ErrTokenInvalid  = errors.New("couldn't handle this token")
)

Functions

func Init

func Init(secretKey string, ttl uint)

Types

type Config

type Config struct {
	SecretKey string
	TTL       uint
}

type CustomClaims

type CustomClaims struct {
	Info interface{} `json:"info"`
	jwt.RegisteredClaims
}

func Parse

func Parse(tokenString string, key string) (*CustomClaims, error)

Parse token by secret key.

func ParseRequest

func ParseRequest(c *gin.Context) (*CustomClaims, error)

ParseRequest Parse token from request header.

type Response

type Response struct {
	AccessToken string    `json:"accessToken"`
	ExpiresAt   time.Time `json:"expiresAt"`
}

func Sign

func Sign(subject string, info interface{}) (*Response, error)

Sign a token by jwt secret.

Jump to

Keyboard shortcuts

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