Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JWTManager ¶
type JWTManager struct {
// contains filtered or unexported fields
}
JWTManager provides our expires time and the secret key to create the tokens
func NewJWTManager ¶
func NewJWTManager(secretKey string, tokenDuration time.Duration) *JWTManager
NewJWTManager returns a JWTManager
func (*JWTManager) GenerateToken ¶
func (manager *JWTManager) GenerateToken(user *UserToken) (string, error)
Generate generates and signs a new token for a user
func (*JWTManager) VerifyToken ¶
func (manager *JWTManager) VerifyToken(accessToken string) (*UserClaims, error)
VerifyToken will return a UserClaims struct or an error
type UserClaims ¶
type UserClaims struct { jwt.StandardClaims UserID string `json:"_id"` Username string `json:"username"` Role string `json:"role"` }
UserClaims privide username
Click to show internal directories.
Click to hide internal directories.