Documentation
¶
Index ¶
- Variables
- func RefreshToken(token string, refreshToken string) (newToken string, err error)
- type JWTUtil
- func (j *JWTUtil) CreateRefreshToken(userID uint) (string, error)
- func (j *JWTUtil) CreateToken(userID uint) (string, error)
- func (j *JWTUtil) DecodeToken(tokenString string) (userID uint, err error)
- func (j *JWTUtil) ExtractToken(c *gin.Context) (token string, err error)
- func (j *JWTUtil) ValidateToken(tokenString string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultRefreshTokenLifeSpanHours time.Duration = 24 * time.Hour //24 hours
DefaultRefreshTokenLifeSpanHours is the default ttl for jwt refresh token
View Source
var DefaultTokenLifeSpan time.Duration = 15 * time.Minute //15 minutes
DefaultTokenLifeSpan is the default ttl for jwt token
View Source
var USER_ID = "userID"
Functions ¶
Types ¶
type JWTUtil ¶
type JWTUtil struct{}
JWTUtil pakcage struct
var JWT *JWTUtil
func (*JWTUtil) CreateRefreshToken ¶
CreateRefreshToken generates new jwt refresh token with the given user id
func (*JWTUtil) CreateToken ¶
CreateToken generates new jwt token with the given user id
func (*JWTUtil) DecodeToken ¶
DecodeToken decodes a given token and returns the user id
func (*JWTUtil) ExtractToken ¶
ExtractToken extracts the token from the request header
Click to show internal directories.
Click to hide internal directories.