feat(admin): list active IP auto-bans and lift a ban, audited #329
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/BUNYIP-319-admin-ip-bans-api"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add an admin-only API surface over the IP auto-ban subsystem. Handlers reach the shared
AutoBanServicevia actix app data (web::Data::fromthe existing Arc registered inmain.rs), so both operations act on the same in-memory ban map the middleware enforces rather than theip_banstable directly.GET /v1/admin/ip-bansreturns every currently-active ban (IP, reason, strikes, banned_at, expires_at) viaAutoBanService::list_bans.BanInfonow derivesSerializeso it renders directly as the response element.DELETE /v1/admin/ip-bans/{ip}parses the path IP (400 on a malformed value), lifts the ban viaAutoBanService::unban(clears the in-memory map, strikes, and the persisted row), returns 404 when the IP was not banned, and records an audit entry on success.AuditAction::AdminIpBanLiftedvariant withas_str=admin_ip_ban_lifted, classified as an admin action; the recorded entry carries the acting admin and target IP.Both routes are AdminUser-guarded. A middleware-level integration test drives the real
AutoBanMiddleware: a banned IP is 403-ed,unbanlifts it, and the same IP's next request passes with 200.#BUNYIP-319
Add an admin-only API surface over the IP auto-ban subsystem. Handlers reach the shared `AutoBanService` via actix app data (`web::Data::from` the existing Arc registered in `main.rs`), so both operations act on the same in-memory ban map the middleware enforces rather than the `ip_bans` table directly. - `GET /v1/admin/ip-bans` returns every currently-active ban (IP, reason, strikes, banned_at, expires_at) via `AutoBanService::list_bans`. `BanInfo` now derives `Serialize` so it renders directly as the response element. - `DELETE /v1/admin/ip-bans/{ip}` parses the path IP (400 on a malformed value), lifts the ban via `AutoBanService::unban` (clears the in-memory map, strikes, and the persisted row), returns 404 when the IP was not banned, and records an audit entry on success. - New `AuditAction::AdminIpBanLifted` variant with `as_str` = `admin_ip_ban_lifted`, classified as an admin action; the recorded entry carries the acting admin and target IP. Both routes are AdminUser-guarded. A middleware-level integration test drives the real `AutoBanMiddleware`: a banned IP is 403-ed, `unban` lifts it, and the same IP's next request passes with 200. #BUNYIP-319