Documentation
¶
Index ¶
- func Auth(required bool, db *gorm.DB, cfg *config.Config, userSvc *service.UserService) func(http.Handler) http.Handler
- func Logging(next http.Handler) http.Handler
- func ParseAndValidateToken(db *gorm.DB, tokenString string, cfg auth.Config) (*auth.Claims, error)
- func RequireRole(allowedRoles ...string) func(http.Handler) http.Handler
- type AuthRateLimit
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Auth ¶
func Auth(required bool, db *gorm.DB, cfg *config.Config, userSvc *service.UserService) func(http.Handler) http.Handler
Auth extracts and validates JWT, attaching claims to context.
func Logging ¶
Logging logs HTTP requests (method, path, status, duration). Skips static assets to reduce noise.
func ParseAndValidateToken ¶
ParseAndValidateToken parses and validates a JWT.
Types ¶
type AuthRateLimit ¶
type AuthRateLimit struct {
// contains filtered or unexported fields
}
AuthRateLimit returns a middleware that limits requests per client IP for auth endpoints. Allows burst requests per window; excess receives 429 Too Many Requests.
func NewAuthRateLimit ¶
func NewAuthRateLimit(limit int, window time.Duration) *AuthRateLimit
NewAuthRateLimit creates a rate limiter: limit requests per IP per window. Example: NewAuthRateLimit(10, time.Minute) = 10 requests per minute per IP.
Click to show internal directories.
Click to hide internal directories.