nutcas3
7ee875c544
feat: Remove ETag generation and validation middleware, simplify CacheMiddleware to basic Cache-Control header
...
- Remove ResponseWriterWrapper struct with Write/Body methods for response body capture
- Remove ETagData/ETagGenerator structs and all ETag generation/validation/caching logic
- Remove generateETag/generateContentETag/generateWeakETag/etagMatches helper functions
- Remove ETagValidationMiddleware/ContentBasedETagMiddleware/CacheInvalidationMiddleware/AdvancedCacheMiddleware handlers
2026-04-24 07:33:07 +03:00
nutcas3
8909126612
feat: Refactor Redis rate limiter to use interface for improved testability and remove mock client replacement pattern
...
- Add RedisClientInterface with Eval/Del/ZCount methods for Redis operation abstraction
- Update RedisRateLimiter/NewRedisRateLimiter/NewMultiTierRateLimiter to accept RedisClientInterface instead of concrete redis.Client
- Update MockRedisClient.Eval to properly construct call arguments with script and keys
- Update MockRedisClient.Del to accept keys as slice instead of variadic parameters
2026-04-23 03:16:00 +03:00
nutcas3
857ca98382
feat: Add comprehensive Redis rate limiter tests with mock client, middleware validation, and multi-tier support
...
- Add MockRedisClient struct with Eval/Del/ZCount methods for Redis operation mocking
- Add TestRedisRateLimiter_Allow with under/over limit scenarios and mock Redis response validation
- Add TestRedisRateLimitMiddleware with IP-based rate limiting and empty key bypass tests
- Add TestIPKeyExtractor/TestUserKeyExtractor/TestAPIKeyExtractor with valid/invalid input validation
- Add TestEnd
2026-04-23 03:02:00 +03:00
nutcas3
85926ee377
feat: Add distributed Redis-based rate limiting with sliding window, token bucket, and multi-tier support
...
- Add RedisRateLimiter struct with client/prefix/limit/window fields for distributed rate limit tracking
- Add RateLimitResult struct with allowed/remaining/reset_time/total_limit/retry_after fields
- Add NewRedisRateLimiter constructor and Allow method with Lua script for atomic sliding window operations
- Add AllowTokenBucket method with token bucket algorithm using Redis HMSET for refill rate
2026-04-23 03:00:33 +03:00
nutcas3
5a3f08829f
feat: Add response body capture to ContentBasedETagMiddleware for accurate content-based ETag generation
...
- Add ResponseWriterWrapper struct with gin.ResponseWriter and body buffer fields to capture response content
- Add Write method to ResponseWriterWrapper that captures response body while writing to original writer
- Add Body method to ResponseWriterWrapper that returns captured response bytes
- Update ContentBasedETagMiddleware to wrap response writer with ResponseWriterWrapper before calling
2026-04-23 02:59:18 +03:00
nutcas3
cae53ebd17
feat: Add comprehensive rate limiting middleware with IP-based, user-based, and endpoint-specific throttling strategies
...
- Add SimpleRateLimiter struct with requests map, mutex, limit, window fields for in-memory rate limit tracking
- Add NewSimpleRateLimiter constructor and Allow method with time-based request cleanup and limit validation
- Add global rate limiters: authRateLimiter (10/min), apiRateLimiter (100/min), readRateLimiter (200/min), adminRateLimiter (50/min)
- Add RateLimit middleware
2026-04-23 02:59:03 +03:00
nutcas3
e2e39d8b37
feat: Add comprehensive API integration tests with authentication, RBAC, and endpoint coverage for all platform handlers
...
- Add TestSetup struct with DB/Router/AuthService/test users/JWT tokens for test environment initialization
- Add setupTest function with SQLite in-memory database, user/plugin/automation/config/auth session migrations, and test user creation with admin/operator/viewer/user roles
- Add makeRequest helper for authenticated HTTP requests with Bearer token and JSON body support
2026-04-23 02:58:34 +03:00
nutcas3
5773cf00bb
feat: Add sophisticated ETag generation with SHA-256 hashing, cache storage, validation middleware, and content-based caching
...
- Add ETagData struct with Path/Method/Content/Timestamp/UserID/Params fields for ETag generation
- Add ETagGenerator struct with secretKey/cacheStorage fields and NewETagGenerator constructor
- Add GenerateETag method with SHA-256 hashing, path/method/content/timestamp/userID/params/secretKey composition
- Add GenerateWeakETag for dynamic content, GetCachedETag/CacheETag for cache operations,
2026-04-23 02:53:01 +03:00
nutcas3
6f3a4e2690
feat: Add performance middleware with request tracking, metrics collection, and optimization utilities
...
- Add PerformanceMetrics struct with requestCount/totalResponseTime/slowRequests/fastRequests/errorRequests fields and sync.RWMutex
- Add PerformanceMiddleware struct with metrics/slowThreshold fields and NewPerformanceMiddleware constructor
- Add Middleware method with request timing, metrics updates, X-Response-Time/X-Request-ID headers, and slow request logging
- Add updateMetrics with request
2026-04-23 02:51:20 +03:00
nutcas3
3eab9c7d60
feat: Add authentication middleware with JWT validation, RBAC permission checks, and role-based access control
...
- Add AuthMiddleware with Authorization header parsing, Bearer token extraction, JWT validation, user lookup, and context storage
- Add RequirePermission middleware with user authentication check, database context retrieval, and permission validation
- Add RequireCasbinPermission middleware with user_id context check, Casbin permission validation, and error handling
- Add RequireRole middleware
2026-04-23 02:38:13 +03:00