Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidIssuer error = fmt.Errorf("Invalid issuer")
View Source
var ErrInvalidToken error = fmt.Errorf("Invalid token")
View Source
var ErrInvalidUser error = fmt.Errorf("Invalid user")
View Source
var ErrTokenMissingClaims error = fmt.Errorf("Token is missing claims")
Functions ¶
This section is empty.
Types ¶
type CreateTokenRequest ¶
type CreateTokenRequest struct { UserID string UserName string AdditionalData map[string]interface{} }
A CreateTokenRequest is used when creating a new JWT token. It contians basic information about a user, and then allows for additional data
type IJWTService ¶
type JWTResponse ¶
type JWTService ¶
type JWTService struct {
// contains filtered or unexported fields
}
JWTService provides methods for working with JWTs in MailSlurper
func NewJWTService ¶
func NewJWTService(config *JWTServiceConfig) *JWTService
NewJWTService creates a new instance of the JWTService struct
func (*JWTService) CreateToken ¶
func (s *JWTService) CreateToken(createRequest *CreateTokenRequest) (string, error)
CreateToken creates a new JWT token and encrypts it
func (*JWTService) GetUserFromToken ¶
func (s *JWTService) GetUserFromToken(token *jwt.Token) (string, string)
GetUserFromToken retrieves the user ID and name from the claims in a JWT token
func (*JWTService) IsTokenValid ¶
func (s *JWTService) IsTokenValid(token *jwt.Token) error
IsTokenValid returns an error if there are any issues with the provided JWT token. Possible issues include:
- Missing claims
- Invalid token format
- Invalid issuer
- User doesn't have a corresponding entry in the credentials table
func (*JWTService) ParseToken ¶
func (s *JWTService) ParseToken(tokenFromHeader string) (*jwt.Token, error)
ParseToken decrypts the provided token and returns a JWT token object
Click to show internal directories.
Click to hide internal directories.