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 JWTAuth ¶
func JWTAuth() gin.HandlerFunc
@Tags Auth @Summary JWT check midware @Description Validate the token field in the request header, parse and verify the JWT. If verification fails, the request will be terminated. @Produce application/json @Success 200 {object} string Note: this is a middleware, not a direct API endpoint JWTAuth 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 (*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
Click to show internal directories.
Click to hide internal directories.