Documentation ¶
Index ¶
- type AccessTokenCustomClaims
- type AuthService
- func (auth *AuthService) Authenticate(reqUser *models.User, user *models.User) bool
- func (auth *AuthService) GenerateAccessToken(user *models.User) (string, error)
- func (auth *AuthService) GenerateCustomKey(userID string, tokenHash string) string
- func (auth *AuthService) GenerateRefreshToken(user *models.User) (string, error)
- func (auth *AuthService) ValidateAccessToken(tokenString string) (string, error)
- func (auth *AuthService) ValidateRefreshToken(tokenString string) (string, string, error)
- type Authentication
- type Mail
- type MailData
- type MailService
- type MailType
- type RefreshTokenCustomClaims
- type SGMailService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessTokenCustomClaims ¶
type AccessTokenCustomClaims struct { UserID string KeyType string jwt.StandardClaims }
AccessTokenCustomClaims specifies the claims for access token
type AuthService ¶
type AuthService struct {
// contains filtered or unexported fields
}
AuthService is the implementation of our Authentication
func NewAuthService ¶
func NewAuthService(logger zap.Logger, configs *utils.Configurations) *AuthService
NewAuthService returns a new instance of the auth service
func (*AuthService) Authenticate ¶
Authenticate checks the user credentials in request against the db and authenticates the request
func (*AuthService) GenerateAccessToken ¶
func (auth *AuthService) GenerateAccessToken(user *models.User) (string, error)
GenerateAccessToken generates a new access token for the given user
func (*AuthService) GenerateCustomKey ¶
func (auth *AuthService) GenerateCustomKey(userID string, tokenHash string) string
GenerateCustomKey creates a new key for our jwt payload the key is a hashed combination of the userID and user tokenhash
func (*AuthService) GenerateRefreshToken ¶
func (auth *AuthService) GenerateRefreshToken(user *models.User) (string, error)
GenerateRefreshToken generate a new refresh token for the given user
func (*AuthService) ValidateAccessToken ¶
func (auth *AuthService) ValidateAccessToken(tokenString string) (string, error)
ValidateAccessToken parses and validates the given access token returns the userId present in the token payload
func (*AuthService) ValidateRefreshToken ¶
func (auth *AuthService) ValidateRefreshToken(tokenString string) (string, string, error)
ValidateRefreshToken parses and validates the given refresh token returns the userId and customkey present in the token payload
type Authentication ¶
type Authentication interface { Authenticate(reqUser *models.User, user *models.User) bool GenerateAccessToken(user *models.User) (string, error) GenerateRefreshToken(user *models.User) (string, error) GenerateCustomKey(userID string, password string) string ValidateAccessToken(token string) (string, error) ValidateRefreshToken(token string) (string, string, error) }
Authentication interface lists the methods that our authentication service should implement
type Mail ¶
type Mail struct {
// contains filtered or unexported fields
}
Mail represents a email request
type MailService ¶
type MailService interface { CreateMail(mailReq *Mail) []byte SendMail(mailReq *Mail) error NewMail(from string, to []string, subject string, mailType MailType, data *MailData) *Mail }
MailService represents the interface for our mail service.
type RefreshTokenCustomClaims ¶
type RefreshTokenCustomClaims struct { UserID string CustomKey string KeyType string jwt.StandardClaims }
RefreshTokenCustomClaims specifies the claims for refresh token
type SGMailService ¶
type SGMailService struct {
// contains filtered or unexported fields
}
SGMailService is the sendgrid implementation of our MailService.
func NewSGMailService ¶
func NewSGMailService(logger zap.Logger, configs *utils.Configurations) *SGMailService
NewSGMailService returns a new instance of SGMailService
func (*SGMailService) CreateMail ¶
func (ms *SGMailService) CreateMail(mailReq *Mail) []byte
CreateMail takes in a mail request and constructs a sendgrid mail type.
func (*SGMailService) NewMail ¶
func (ms *SGMailService) NewMail(from string, to []string, subject string, mailType MailType, data *MailData) *Mail
NewMail returns a new mail request.
func (*SGMailService) SendMail ¶
func (ms *SGMailService) SendMail(mailReq *Mail) error
SendMail creates a sendgrid mail from the given mail request and sends it.