Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrExpiredToken = errors.New("token has expired")
View Source
var ErrInvalidToken = errors.New("token is invalid")
Functions ¶
This section is empty.
Types ¶
type PasetoBuilder ¶
type PasetoBuilder struct {
// contains filtered or unexported fields
}
func (*PasetoBuilder) CreateToken ¶
func (builder *PasetoBuilder) CreateToken(p PayloadData, duration time.Duration) (string, *Payload, error)
func (*PasetoBuilder) VerifyToken ¶
func (builder *PasetoBuilder) VerifyToken(token string) (*Payload, error)
Verifys token integrity and expiration time
type Payload ¶
type Payload struct { Id uuid.UUID `json:"id,omitempty"` IssuedAt time.Time `json:"iat,omitempty"` ExpiresAt time.Time `json:"expires,omitempty"` Payload PayloadData `json:"payload,omitempty"` }
func NewPayload ¶
func NewPayload(p PayloadData, duration time.Duration) (*Payload, error)
type PayloadData ¶
type PayloadData struct { UserID uuid.UUID `json:"user_id,omitempty"` UserEmail string `json:"user_email,omitempty"` RecoveryCode string `json:"recovery_code,omitempty"` DeletionCode string `json:"deletion_code,omitempty"` VerificationCode string `json:"email_verification_code,omitempty"` AllowIP string `json:"allow_ip,omitempty"` AllowIPCode string `json:"allow_ip_code,omitempty"` }
type TokenBuilder ¶
type TokenBuilder interface { // Create Token if token for specific duration CreateToken(data PayloadData, duration time.Duration) (string, *Payload, error) // Validates token integrity and expiration time VerifyToken(token string) (*Payload, error) }
TokenBuilder is an interface for managing tokens
func NewPasetoBuilder ¶
func NewPasetoBuilder(symmetricKey string) (TokenBuilder, error)
Click to show internal directories.
Click to hide internal directories.