Documentation
¶
Index ¶
- Variables
- type AuthHandler
- func (h *AuthHandler) Logout(c *echo.Context) error
- func (h *AuthHandler) Refresh(c *echo.Context) error
- func (h *AuthHandler) Register(c *echo.Context) error
- func (h *AuthHandler) RequestMagicLink(c *echo.Context) error
- func (h *AuthHandler) Verify(c *echo.Context) error
- func (h *AuthHandler) VerifyRedirect(c *echo.Context) error
- type AuthRepository
- func (r *AuthRepository) CreateMagicLinkToken(ctx context.Context, token MagicLinkToken) error
- func (r *AuthRepository) CreateRefreshToken(ctx context.Context, token RefreshToken) error
- func (r *AuthRepository) GetMagicLinkToken(ctx context.Context, token string) (MagicLinkToken, error)
- func (r *AuthRepository) GetRefreshTokenByHash(ctx context.Context, hash string) (*RefreshToken, error)
- func (r *AuthRepository) MarkMagicLinkTokenAsUsed(ctx context.Context, tokenId uuid.UUID) error
- func (r *AuthRepository) RevokeAllUserRefreshTokens(ctx context.Context, userID uuid.UUID) error
- func (r *AuthRepository) RevokeRefreshToken(ctx context.Context, tokenID uuid.UUID) error
- type AuthService
- func (s *AuthService) CreateMagicLink(ctx context.Context, email string) error
- func (s *AuthService) LoginWithMagicLink(ctx context.Context, token string) (*LoginResponse, error)
- func (s *AuthService) Logout(ctx context.Context, rawRefreshToken string) error
- func (s *AuthService) RefreshAccessToken(ctx context.Context, rawRefreshToken string) (*LoginResponse, error)
- func (s *AuthService) Register(ctx context.Context, email string, name string) error
- type LoginResponse
- type LogoutRequest
- type MagicLinkRequest
- type MagicLinkToken
- type RefreshRequest
- type RefreshToken
- type RegisterRequest
- type VerifyRequest
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUserNotFound = errors.New("user not found") ErrUserAlreadyExists = errors.New("user already exists") ErrInvalidToken = errors.New("invalid token") ErrExpiredToken = errors.New("token has expired") ErrMissingToken = errors.New("token is required") ErrTokenAlreadyUsed = errors.New("token already used") ErrInvalidRefreshToken = errors.New("invalid refresh token") ErrExpiredRefreshToken = errors.New("refresh token has expired") ErrRevokedRefreshToken = errors.New("refresh token has been revoked") )
Functions ¶
This section is empty.
Types ¶
type AuthHandler ¶
type AuthHandler struct {
// contains filtered or unexported fields
}
func NewAuthHandler ¶
func NewAuthHandler(service service) *AuthHandler
func (*AuthHandler) RequestMagicLink ¶
func (h *AuthHandler) RequestMagicLink(c *echo.Context) error
func (*AuthHandler) VerifyRedirect ¶
func (h *AuthHandler) VerifyRedirect(c *echo.Context) error
type AuthRepository ¶
type AuthRepository struct {
// contains filtered or unexported fields
}
func NewAuthRepository ¶
func NewAuthRepository(db *gorm.DB) *AuthRepository
func (*AuthRepository) CreateMagicLinkToken ¶
func (r *AuthRepository) CreateMagicLinkToken(ctx context.Context, token MagicLinkToken) error
func (*AuthRepository) CreateRefreshToken ¶
func (r *AuthRepository) CreateRefreshToken(ctx context.Context, token RefreshToken) error
func (*AuthRepository) GetMagicLinkToken ¶
func (r *AuthRepository) GetMagicLinkToken(ctx context.Context, token string) (MagicLinkToken, error)
func (*AuthRepository) GetRefreshTokenByHash ¶
func (r *AuthRepository) GetRefreshTokenByHash(ctx context.Context, hash string) (*RefreshToken, error)
func (*AuthRepository) MarkMagicLinkTokenAsUsed ¶
func (*AuthRepository) RevokeAllUserRefreshTokens ¶
func (*AuthRepository) RevokeRefreshToken ¶
type AuthService ¶
type AuthService struct {
// contains filtered or unexported fields
}
func NewAuthService ¶
func NewAuthService(repository repository, users userRepository, emailSender emailSender, jwtManager *utils.JWTManager, magicLinkTokenDuration time.Duration, refreshTokenDuration time.Duration) *AuthService
func (*AuthService) CreateMagicLink ¶
func (s *AuthService) CreateMagicLink(ctx context.Context, email string) error
func (*AuthService) LoginWithMagicLink ¶
func (s *AuthService) LoginWithMagicLink(ctx context.Context, token string) (*LoginResponse, error)
func (*AuthService) Logout ¶
func (s *AuthService) Logout(ctx context.Context, rawRefreshToken string) error
func (*AuthService) RefreshAccessToken ¶
func (s *AuthService) RefreshAccessToken(ctx context.Context, rawRefreshToken string) (*LoginResponse, error)
type LoginResponse ¶
type LogoutRequest ¶
type LogoutRequest struct {
RefreshToken string `json:"refresh_token" validate:"required"`
}
type MagicLinkRequest ¶
type MagicLinkRequest struct {
Email string `json:"email" validate:"required,email"`
}
type MagicLinkToken ¶
type RefreshRequest ¶
type RefreshRequest struct {
RefreshToken string `json:"refresh_token" validate:"required"`
}
type RefreshToken ¶
type RefreshToken struct {
TokenID uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"`
UserID uuid.UUID `gorm:"not null;index"`
TokenHash string `gorm:"column:token_hash;not null;uniqueIndex"`
ExpiresAt time.Time `gorm:"not null"`
CreatedAt time.Time `gorm:"autoCreateTime"`
RevokedAt *time.Time
}
type RegisterRequest ¶
type VerifyRequest ¶
type VerifyRequest struct {
Token string `json:"token" validate:"required"`
}
Click to show internal directories.
Click to hide internal directories.