token

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 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 GetBearerToken added in v0.2.0

func GetBearerToken(c *gin.Context) string

GetBearerToken Get bearer token from request header.

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.

func ParseToken added in v0.3.4

func ParseToken(c *gin.Context, token string) (*CustomClaims, error)

ParseToken Parse given token.

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