Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrUnexpectedSigningMethod is returned when the signing method is unexpected. ErrUnexpectedSigningMethod = fmt.Errorf("unexpected signing method") )
Functions ¶
This section is empty.
Types ¶
type TokenManager ¶
type TokenManager struct {
// contains filtered or unexported fields
}
TokenManager manages JWT tokens.
func NewTokenManager ¶
func NewTokenManager(secretKey string, tokenDuration time.Duration) *TokenManager
NewTokenManager creates a new TokenManager.
func (*TokenManager) Generate ¶
func (m *TokenManager) Generate(username string) (string, error)
Generate generates a new token for the user.
func (*TokenManager) Verify ¶
func (m *TokenManager) Verify(token string) (*UserClaims, error)
Verify verifies the given token.
type UserClaims ¶
type UserClaims struct { jwt.StandardClaims Username string `json:"username"` }
UserClaims is a JWT claims struct for a user.
Click to show internal directories.
Click to hide internal directories.