thirdjwt

package
v0.0.0-...-de7d92c Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateToken

func GenerateToken(claims jwt.Claims) (string, error)

func ParseToken

func ParseToken(tokenString string) (map[string]interface{}, error)

func Secret

func Secret() jwt.Keyfunc

func TokenValidationMiddleware

func TokenValidationMiddleware(next http.Handler) http.Handler

We want all our routes for REST to be authenticated. So, we validate the token

func ValidatePayloadToken

func ValidatePayloadToken(tokenString string, secret string) (bool, error)

func ValidateToken

func ValidateToken(tokenString string, secret string) (bool, error)

Types

type Payload

type Payload struct {
	jwt.RegisteredClaims // 注意!这是jwt-go的v4版本新增的,原先是jwt.StandardClaims
	basic.User
	Phone string `json:"phone"`
}

func ParsePayloadToken

func ParsePayloadToken(tokenString string) (*Payload, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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