Documentation
¶
Index ¶
- Variables
- type AuthService
- func (s *AuthService) GenerateTokensPair(ctx context.Context, userEmail EmailString, otp OTPString) (string, string, error)
- func (s *AuthService) IsEnabled() bool
- func (s *AuthService) RefreshToken(ctx context.Context, oldRefreshToken string) (string, string, error)
- func (s *AuthService) SendOTP(ctx context.Context, userEmail EmailString) error
- func (s *AuthService) ValidateAccessToken(ctx context.Context, accessToken string) (*Claims, error)
- func (s *AuthService) ValidateRefreshToken(ctx context.Context, refreshToken string) (*Claims, error)
- type AuthTokenType
- type Claims
- type Config
- type EmailString
- type OTPString
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidEmail = utils.ErrInvalidEmail ErrInvalidOTP = errors.New("invalid otp") ErrInvalidToken = errors.New("invalid token") ErrInvalidRequestToken = errors.New("invalid request token") ErrInvalidAccessToken = errors.New("invalid access token") ErrInvalidRefreshToken = errors.New("invalid refresh token") )
Functions ¶
This section is empty.
Types ¶
type AuthService ¶
type AuthService struct {
// contains filtered or unexported fields
}
func NewAuthService ¶
func NewAuthService(config *Config, emailSvc email.Service) *AuthService
func (*AuthService) GenerateTokensPair ¶
func (s *AuthService) GenerateTokensPair(ctx context.Context, userEmail EmailString, otp OTPString) (string, string, error)
func (*AuthService) IsEnabled ¶
func (s *AuthService) IsEnabled() bool
func (*AuthService) RefreshToken ¶
func (*AuthService) SendOTP ¶
func (s *AuthService) SendOTP(ctx context.Context, userEmail EmailString) error
func (*AuthService) ValidateAccessToken ¶
func (*AuthService) ValidateRefreshToken ¶
type AuthTokenType ¶
type AuthTokenType string
const ( AccessToken AuthTokenType = "access" RefreshToken AuthTokenType = "refresh" )
type Claims ¶
type Claims struct {
Type AuthTokenType `json:"type"`
jwt.RegisteredClaims
}
func ParseClaims ¶
type Config ¶
type Config struct {
Enabled bool `mapstructure:"enabled"`
TokenIssuer string `mapstructure:"token_issuer"`
RefreshTokenSecret string `mapstructure:"refresh_token_secret"`
RefreshTokenExpiry time.Duration `mapstructure:"refresh_token_expiry"`
AccessTokenSecret string `mapstructure:"access_token_secret"`
AccessTokenExpiry time.Duration `mapstructure:"access_token_expiry"`
EmailAddr string `mapstructure:"email_addr"`
EmailOTPLength int `mapstructure:"email_otp_length"`
EmailOTPExpiry time.Duration `mapstructure:"email_otp_expiry"`
}
type EmailString ¶ added in v0.7.0
type EmailString = string
Click to show internal directories.
Click to hide internal directories.