Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrExpiredToken = errors.New("token has expired") ErrInvalidToken = errors.New("token is invalid") )
Errors returned from ValidateToken method.
Functions ¶
This section is empty.
Types ¶
type Generator ¶
type Generator interface { // GenerateToken creates a new token for the specified user. GenerateToken(userID int64, duration time.Duration) (string, *Payload, error) // ValidateToken validates if the token is proper. ValidateToken(token string) (*Payload, error) }
Generator is a token management interface.
func NewJWTGenerator ¶
NewJWTGenerator creates a new JWT Generator.
func NewPasetoGenerator ¶
NewJWTGenerator creates a new PASETO Generator.
type JWTGenerator ¶
type JWTGenerator struct {
// contains filtered or unexported fields
}
JWTGenerator struct represents a JSON Web Token generator.
func (*JWTGenerator) GenerateToken ¶
func (g *JWTGenerator) GenerateToken(userID int64, duration time.Duration) (string, *Payload, error)
GenerateToken creates a new token for the specified user.
func (*JWTGenerator) ValidateToken ¶
func (g *JWTGenerator) ValidateToken(token string) (*Payload, error)
ValidateToken validates if the token is proper.
type PasetoGenerator ¶
type PasetoGenerator struct {
// contains filtered or unexported fields
}
PasetoGenerator struct represents a PASETO token generator.
func (*PasetoGenerator) GenerateToken ¶
func (g *PasetoGenerator) GenerateToken(userID int64, duration time.Duration) (string, *Payload, error)
GenerateToken creates a new token for the specified user.
func (*PasetoGenerator) ValidateToken ¶
func (g *PasetoGenerator) ValidateToken(token string) (*Payload, error)
ValidateToken validates if the token is proper.
Click to show internal directories.
Click to hide internal directories.