Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JWTMaker ¶
type JWTMaker struct {
// contains filtered or unexported fields
}
JWTMaker is a JSON Web Token maker.
func (*JWTMaker) CreateToken ¶
CreateToken creates a new token for a specific username and duration.
type PasteoMaker ¶
type PasteoMaker struct {
// contains filtered or unexported fields
}
PasteoMaker is a real implementation of the TokenMaker interface.
func (*PasteoMaker) CreateToken ¶
CreateToken creates a new token for a specific username and duration.
func (*PasteoMaker) VerifyToken ¶
func (maker *PasteoMaker) VerifyToken(token string) (*Payload, error)
VerifyToken checks if the token is valid or not.
type Payload ¶
type Payload struct { ID uuid.UUID `json:"id"` Username string `json:"username"` IssueAt time.Time `json:"issue_at"` ExpireAt time.Time `json:"expire_at"` }
Payload is the output of the token creation process.
type TokenMaker ¶
type TokenMaker interface { // CreateToken creates a new token for a specific username and duration. CreateToken(username string, duration time.Duration) (string, error) // VerifyToken checks if the token is valid or not. VerifyToken(token string) (*Payload, error) }
TokenMaker is an interface that creates and verifies tokens.
func NewJWTMaker ¶
func NewJWTMaker(secretKey string) (TokenMaker, error)
NewJWTMaker creates a new JWTMaker.
func NewPasteoMaker ¶
func NewPasteoMaker(symmetricKey string) (TokenMaker, error)
NewPasteoMaker creates a new PasteoMaker.
Click to show internal directories.
Click to hide internal directories.