Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidJWTKeySize = errors.New(fmt.Sprintf("Invalid key size: must be at least %v characters", minJWTSecretKeySize)) ErrMissingCustomDuration = errors.New("Duration must be provided for CustomToken") ErrTooManyCustomDuration = errors.New("Provide too many durations") ErrInvalidTokenType = errors.New("Invalid token type") )
View Source
var ( ErrInvalidToken = errors.New("Token is invalid") ErrExpiredToken = errors.New("Token has expired") )
View Source
var (
ErrInvalidPasetoKeySize = errors.New(fmt.Sprintf("Invalid key size: must be exactly %d charaters", pasetoSymmetricKeySize))
)
Functions ¶
func NewJWTMaker ¶
func NewJWTMaker(id string) *jwtMaker
func NewPasetoMaker ¶
func NewPasetoMaker(id string) *pasetoMaker
Types ¶
type Payload ¶
type Payload struct { ID uuid.UUID `json:"id"` UID string `json:"uid"` IssuedAt time.Time `json:"issued_at"` ExpiredAt time.Time `json:"expired_at"` }
Payload contains the payload data of the token
func NewPayload ¶
NewPayload creates a new token payload with a specific username and duration
type TokenMaker ¶
type TokenMaker interface { // CreateToken creates a new token for a specific uid and duration // For TokenType CustomToken, duration must be provided explicitly. CreateToken(tokenType TokenType, uid string, duration ...time.Duration) (string, *Payload, error) // VerifyToken checks if a token is valid or not VerifyToken(token string) (*Payload, error) }
Click to show internal directories.
Click to hide internal directories.