Documentation ¶
Index ¶
Constants ¶
View Source
const ( // ErrInvalidKeySize indicates error for invalidate token key. // The chacha20poly1305 algo requires a 32 byte or character key. ErrInvalidKeySize = "invalid key size: must be exactly %d characters" // Issuer indicates the creator of the token Issuer = "coderaOJ.com" )
View Source
const ( // ErrInvalidToken indicates the error of token invalidation ErrInvalidToken = "token is invalid: %v" // ErrExpiredToken indicated the error of token expiration ErrExpiredToken = "token is expired" )
Variables ¶
This section is empty.
Functions ¶
func NewPasetoPayload ¶
NewPasetoPayload creates Payload instance for specific username and duration
Types ¶
type ClaimsInfo ¶
ClaimsInfo holds the claims information for a user
type PasetoToken ¶
type PasetoToken struct {
// contains filtered or unexported fields
}
PasetoToken describes a paseto token
func (*PasetoToken) CreateToken ¶
func (pt *PasetoToken) CreateToken(claimsInfo *ClaimsInfo, duration time.Duration) (*TokenInfo, error)
CreateToken creates a new token for a specific username and duration
func (*PasetoToken) VerifyToken ¶
func (pt *PasetoToken) VerifyToken(token string) (*paseto.JSONToken, error)
VerifyToken verifies if the given token is valid or not. And also returns the payload if the token is valid.
type TokenManager ¶
type TokenManager interface { CreateToken(claimsInfo *ClaimsInfo, duration time.Duration) (*TokenInfo, error) VerifyToken(token string) (*paseto.JSONToken, error) }
TokenManager is the interface for managing tokens
func NewPasetoToken ¶
func NewPasetoToken(symmetricKey []byte) (TokenManager, error)
NewPasetoToken creates PasetoToken instance
Click to show internal directories.
Click to hide internal directories.