feat: enhance auth, add input validation and pagination

- Add IP validation in auth handler with detailed logging
- Implement apiKeyMiddleware helper for API key verification
- Add IP and CIDR validation for whitelist operations
- Support pagination for listing temp and permanent entries
- Add parsePagination helper to extract limit and offset
- Include comprehensive unit tests for IsIP, IsCIDR, and IPMatch
This commit is contained in:
db123-test
2026-05-05 11:34:35 +03:30
parent 93c9eb2a45
commit f525eaa8f3
5 changed files with 383 additions and 17 deletions

View File

@@ -1,13 +1,21 @@
package main
import (
"context"
"database/sql"
"time"
)
func cleanupLoop(db *sql.DB, interval time.Duration) {
func cleanupLoop(ctx context.Context, db *sql.DB, interval time.Duration) {
ticker := time.NewTicker(interval)
for range ticker.C {
_ = CleanupExpiredTemp(db)
defer ticker.Stop()
for {
select {
case <-ctx.Done():
return
case <-ticker.C:
_ = CleanupExpiredTemp(db)
_ = RotateAuditLog(db, 0)
}
}
}