Documentation ¶
Index ¶
- Constants
- Variables
- type JWT
- func (j *JWT) CreateToken(id int64, name string) (string, error)
- func (j *JWT) IsRevoked(tokenString string) bool
- func (j *JWT) ParseToken(tokenString string) (*UserClaims, error)
- func (j *JWT) RefreshToken(tokenString string) (string, error)
- func (j *JWT) RefreshTokenUnverified(tokenString string) (string, error)
- func (j *JWT) RevokeToken(tokenString string) error
- type UserClaims
Constants ¶
View Source
const ExpiredTime zone.Duration = 4 * zone.Hour //@todo move to configuration
View Source
const MaxRefreshTimes uint = 1
View Source
const REFRESH_TOKEN_CACHE_KEY = "TMAIC_REFRESH_TOKEN_%s"
View Source
const REVOKED_TOKEN_CACHE_KEY = "TMAIC_REVOKED_TOKEN_%s"
View Source
const RefreshExpiredTime zone.Duration = 10 * time.Minute
Variables ¶
View Source
var ( TokenExpired error = errors.New("Token is expired") TokenNotValidYet error = errors.New("Token not active yet") TokenMalformed error = errors.New("That's not even a token") TokenInvalid error = errors.New("Couldn't handle this token") TokenNoSet error = errors.New("Token is not set") )
Functions ¶
This section is empty.
Types ¶
type JWT ¶
type JWT struct {
SigningKey []byte
}
func (*JWT) ParseToken ¶
func (j *JWT) ParseToken(tokenString string) (*UserClaims, error)
func (*JWT) RefreshTokenUnverified ¶
func (*JWT) RevokeToken ¶
type UserClaims ¶
type UserClaims struct { ID int64 `json:"id"` Name string `json:"name"` Revoked bool `json:"revoked"` jwt.StandardClaims }
func (UserClaims) Valid ¶
func (c UserClaims) Valid() error
Click to show internal directories.
Click to hide internal directories.