Documentation ¶
Index ¶
Constants ¶
View Source
const MIN_SECRET_KEY_SIZE = 32
Variables ¶
View Source
var ( ErrInvalidToken = errors.New("token is invalid") ErrExpiredToken = errors.New("token has expired") )
Different types of error returned by the VerifyToken function
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator interface { // CreateToken creates a new token for a specific client sub and duration CreateToken(sub uuid.UUID, role string, duration time.Duration) (string, *Payload, error) // VerifyToken checks if the token is valid or not VerifyToken(token string) (*Payload, error) }
Authenticator is an interface for managing tokens
func CreateJWTAuditor ¶
func CreateJWTAuditor(secretKey string) (Authenticator, error)
func CreatePasetoAuditor ¶
func CreatePasetoAuditor(symmetricKey string) (Authenticator, error)
type JWTAuditor ¶
type JWTAuditor struct {
// contains filtered or unexported fields
}
func (*JWTAuditor) CreateToken ¶
func (*JWTAuditor) VerifyToken ¶
func (auditor *JWTAuditor) VerifyToken(token string) (*Payload, error)
type PasetoAuditor ¶
type PasetoAuditor struct {
// contains filtered or unexported fields
}
func (*PasetoAuditor) CreateToken ¶
func (*PasetoAuditor) VerifyToken ¶
func (auditor *PasetoAuditor) VerifyToken(token string) (*Payload, error)
type Payload ¶
type Payload struct { ID uuid.UUID `json:"id"` Sub uuid.UUID `json:"sub"` Role string `json:"role"` Issued time.Time `json:"issued"` Expired time.Time `json:"expired"` }
Payload contains the payload data of the token
func CreatePayload ¶
CreatePayload creates a new token payload with a specific username and duration
Click to show internal directories.
Click to hide internal directories.