auth

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

type TokenPair

type TokenPair struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    int64  `json:"expires_in"` // seconds until access_token expires
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL