auth

package
v0.0.0-...-5f47394 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TokenExpired     error  = errors.New("Token is expired")
	TokenNotValidYet error  = errors.New("Token is not valid yet")
	TokenMalformed   error  = errors.New("This is not a token")
	TokenInvalid     error  = errors.New("Couldn't handle this token")
	SignKey          string = "dubbo-go-pixiu" // TODO: The signature information is set to be dynamically obtained
)

Constant

Functions

func GetSignKey

func GetSignKey() string

get signKey

func JWTAuth

func JWTAuth() gin.HandlerFunc

Check token

Types

type CustomClaims

type CustomClaims struct {
	Username string `json:"username"`
	// The StandardClaims structure implements the Claims interface (Valid() function)
	jwt.StandardClaims
}

Custom Claims

type JWT

type JWT struct {
	SigningKey []byte
}

JWT Signature structure

func NewJWT

func NewJWT() *JWT

New jwt instance

func (*JWT) CreateToken

func (j *JWT) CreateToken(claims CustomClaims) (string, error)

CreateToken Generate token (based on user basic information) HS256 algorithm

func (*JWT) ParseToken

func (j *JWT) ParseToken(tokenString string) (*CustomClaims, error)

ParseToken

func (*JWT) RefreshToken

func (j *JWT) RefreshToken(tokenString string) (string, error)

Update token

Jump to

Keyboard shortcuts

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