feat: add SQLite persistence and REST API for temporary whitelisting
- Migrate IP-based temporary whitelisting from file to SQLite storage - Add REST API endpoints for managing temporary and permanent whitelists - Create `.env.example` with required environment variables - Document API endpoints in README.md and docs/api.md - Add new dependency `modernc.org/sqlite` for SQLite support - Update deployment and security documentation
This commit is contained in:
9
auth.go
9
auth.go
@@ -6,6 +6,7 @@ import (
|
||||
"log/slog"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func CheckAuth(db *sql.DB, r *http.Request) bool {
|
||||
@@ -130,10 +131,10 @@ func logsHandler(cfg Config, db *sql.DB) http.HandlerFunc {
|
||||
continue
|
||||
}
|
||||
entry := map[string]interface{}{
|
||||
"timestamp": ts,
|
||||
"action": action,
|
||||
"timestamp": ts,
|
||||
"action": action,
|
||||
"api_client_ip": apiClientIP,
|
||||
"reason": reason,
|
||||
"reason": reason,
|
||||
}
|
||||
if ip.Valid {
|
||||
entry["ip"] = ip.String
|
||||
@@ -218,4 +219,4 @@ func verifyAPIKey(r *http.Request, expectedToken string) bool {
|
||||
func statusHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.Write([]byte("ok\n"))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user