Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Cors ¶
func Cors() gin.HandlerFunc
func JWTAuth ¶
func JWTAuth() gin.HandlerFunc
Types ¶
type BaseClaims ¶
type CustomClaims ¶
type CustomClaims struct { BaseClaims BufferTime int64 jwt.StandardClaims }
Custom claims structure
func GetUserInfo ¶
func GetUserInfo(c *gin.Context) *CustomClaims
Get the user roles parsed from jwt from the Context of Gin
type JWT ¶
type JWT struct {
SigningKey []byte
}
func (*JWT) CreateClaims ¶
func (j *JWT) CreateClaims(baseClaims BaseClaims) CustomClaims
func (*JWT) CreateToken ¶
func (j *JWT) CreateToken(claims CustomClaims) (string, error)
create a token
func (*JWT) CreateTokenByOldToken ¶
func (j *JWT) CreateTokenByOldToken(oldToken string, claims CustomClaims) (string, error)
Replacing old token with new token using merging and origin-pull to avoid concurrency problems
func (*JWT) ParseToken ¶
func (j *JWT) ParseToken(tokenString string) (*CustomClaims, error)
Click to show internal directories.
Click to hide internal directories.