Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JWTMiddleware ¶
func JWTMiddleware(jwtSvc *JWTService) gin.HandlerFunc
Types ¶
type AuthHandler ¶
type AuthHandler struct {
// contains filtered or unexported fields
}
func NewAuthHandler ¶
func NewAuthHandler(username, password string, jwtSvc *JWTService, rateLimiter *LoginRateLimiter) *AuthHandler
func (*AuthHandler) Login ¶
func (h *AuthHandler) Login(c *gin.Context)
func (*AuthHandler) Refresh ¶
func (h *AuthHandler) Refresh(c *gin.Context)
type Claims ¶
type Claims struct {
Type string `json:"type"`
jwt.RegisteredClaims
}
type JWTService ¶
type JWTService struct {
// contains filtered or unexported fields
}
func NewJWTService ¶
func NewJWTService(secret string, accessTTL, refreshTTL time.Duration) *JWTService
func (*JWTService) GenerateAccessToken ¶
func (s *JWTService) GenerateAccessToken() (string, int64, error)
func (*JWTService) GenerateTokenPair ¶
func (s *JWTService) GenerateTokenPair() (*TokenPair, error)
func (*JWTService) ValidateAccessToken ¶
func (s *JWTService) ValidateAccessToken(tokenStr string) error
func (*JWTService) ValidateRefreshToken ¶
func (s *JWTService) ValidateRefreshToken(tokenStr string) error
type LoginRateLimiter ¶
type LoginRateLimiter struct {
// contains filtered or unexported fields
}
func NewLoginRateLimiter ¶
func NewLoginRateLimiter(maxAttempts int, window time.Duration) *LoginRateLimiter
func (*LoginRateLimiter) Allow ¶
func (l *LoginRateLimiter) Allow(ip string) bool
Click to show internal directories.
Click to hide internal directories.