Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrorInvalidToken = errors.New("token is invalid") ErrExpiredToken = errors.New("token has expired") )
Functions ¶
This section is empty.
Types ¶
type JWTMaker ¶
type JWTMaker struct {
// contains filtered or unexported fields
}
type Maker ¶
type Maker interface { //create token for a specific username and duration CreateToken(username string, duration time.Duration) (string, *Payload, error) //check is the token is valid or not VerifyToken(token string) (*Payload, error) }
interface for making token
func NewJWTMaker ¶
func NewPasetoMaker ¶
type PasetoMaker ¶
type PasetoMaker struct {
// contains filtered or unexported fields
}
func (*PasetoMaker) CreateToken ¶
func (maker *PasetoMaker) CreateToken(username string, duration time.Duration) (string, *Payload, error)
create token for a specific username and duration
func (*PasetoMaker) VerifyToken ¶
func (maker *PasetoMaker) VerifyToken(token string) (*Payload, error)
check is the token is valid or not
type Payload ¶
type Payload struct { ID uuid.UUID `json:"id"` Username string `json:"username"` IssuedAt time.Time `json:"issued_at"` ExpiredAt time.Time `json:"expired_at"` }
func NewPayload ¶
payload: contains verifiable security statements, such as the identity of the user and the permissions they are allowed.
Click to show internal directories.
Click to hide internal directories.