Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidSecret is returned when an empty secret is given ErrInvalidSecret = errors.New("Please provide a valid secret") // ErrInvalidToken is returned when trying to parse an invalid token ErrInvalidToken = errors.New("Token is invalid") )
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator interface { GenerateToken(*types.User) (string, error) CheckToken(string) error }
Authenticator describes how an authenticator should operate
func NewJWTAuthenticator ¶
func NewJWTAuthenticator(secret []byte) (Authenticator, error)
NewJWTAuthenticator returns a new instance of a JWTAuthenticator
type JWTAuthenticator ¶
type JWTAuthenticator struct {
// contains filtered or unexported fields
}
JWTAuthenticator handles generating and parsing JWTs
func (JWTAuthenticator) CheckToken ¶
func (a JWTAuthenticator) CheckToken(tokenString string) error
CheckToken attempts to parse an auth token
func (JWTAuthenticator) GenerateToken ¶
func (a JWTAuthenticator) GenerateToken(u *types.User) (string, error)
GenerateToken takes a user and generates a JWT containing their user ID
Click to show internal directories.
Click to hide internal directories.