feat(admin): move auto-ban config into DB admin settings (BUNYIP-351) #350
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/BUNYIP-351-auto-ban-db-config"
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?
What
Phase 1 of BUNYIP-351: move the auto-ban thresholds out of env-only vars and into a DB-persisted, admin-editable singleton, following the established
tier_config/stripe_configDB-overrides-env pattern.AUTO_BAN_ENABLED,AUTO_BAN_THRESHOLD,AUTO_BAN_WINDOW_SECS, andAUTO_BAN_DURATION_SECSremain the bootstrap defaults. Once an admin edits the values in the new Auto-ban settings page, theauto_ban_configrow overrides them and the change applies immediately with no restart. A wiped DB (all-NULL row) falls straight back to the env defaults, so a fresh deployment boots identically.How
auto_ban_config(id CHECK=1, nullable columns, updated_at/updated_by), seeded id=1. Additive and immutable.AutoBanConfigRow+AutoBanConfigResponsemodel;AutoBanConfig::from_db_row/has_db_overridesmerge (mirrorsTierConfig).AutoBanConfignow derivesCopy.AutoBanConfigRepository(get+ COALESCE partialupdate).AutoBanServiceholds its config behind astd::sync::RwLockand gainsreload(). Values were already read per-request off a frozen copy, so this is the only refactor needed for live apply; a cheapCopy-out snapshot keeps the hot path lock-light.main.rs(env fallback).GET/PUT /v1/admin/auto-ban-confighandlers, routes, and anAdminAutoBanConfigUpdatedaudit action; the PUT hot-reloads the running service./admin/auto-ban-settings(api client, types DTO, page + save handler,shield-alerticon)..env.exampledocuments the vars as bootstrap defaults now overridable in the admin UI.Tests
cargo fmt --check,cargo clippy --workspace --all-targets -D warnings, andcargo test --workspace --all-targetsall green in the pinned rust-builder container. New unit tests coverfrom_db_rowenv-fallback, override, and out-of-range-clamp paths.Scope
Stripe secrets and tier config were already DB-backed. Email/SMTP config (phase 2, includes an encrypted SMTP password reusing the Stripe encryption key set) and the leftover Stripe checkout knobs (phase 3) follow in later PRs. The revised ticket describes all three phases.
🤖 Generated with Claude Code
https://claude.ai/code/session_01CTpxCd1SvpE8sk82aGikkz