Add admin IP whitelist gate (ADMIN_SECRETS) to UI #9
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Context
The UI currently accepts any connection on its UDS. Every Hero admin UI enforces an IP whitelist backed by the
ADMIN_SECRETSsecret in hero_proc (hero_ui_whitelistsskill). The TCP gate runs before the HTTP router, is cached, refreshes periodically, and fails open if hero_proc is unreachable.Goals
whitelistmodule (perhero_ui_whitelists§Rust implementation).ADMIN_SECRETSsecret viahero_proc_sdkon boot; cache the parsed CIDR list.PUT /admin/whitelistbehind the same gate for write-through updates (optional but standard).Related skills:
hero_ui_whitelists,hero_proc_secrets,hero_proc_sdk.Implementation Spec for Issue #9
Objective
Add an IP-based whitelist gate to hero_livekit_ui that loads allowed CIDR ranges from the ADMIN_SECRETS secret in hero_proc, caches them, enforces them as axum middleware on every inbound HTTP request (reading the client IP from X-Forwarded-For / X-Real-Ip headers), refreshes periodically in the background, and fails open with a warning when hero_proc is unreachable.
Requirements
Files to Modify/Create
crates/hero_livekit_ui/src/whitelist.rs- New: WhitelistState, CIDR loading/parsing, axum middleware, background refresh task, optional PUT endpointcrates/hero_livekit_ui/src/main.rs- Modify: add mod whitelist, initialize WhitelistState on boot, wire middleware into Router, spawn refresh taskcrates/hero_livekit_ui/Cargo.toml- Modify: add ipnetwork = "0.20" dependencyImplementation Plan
Step 1: Add ipnetwork dependency
Files:
crates/hero_livekit_ui/Cargo.tomlDependencies: none
Step 2: Create the whitelist.rs module
Files:
crates/hero_livekit_ui/src/whitelist.rsDependencies: Step 1
Step 3: Wire the whitelist into main.rs
Files:
crates/hero_livekit_ui/src/main.rsDependencies: Step 2
Acceptance Criteria
Notes
Test Results
All tests pass. cargo build -p hero_livekit_ui and cargo test both succeed with no errors or warnings.
Implementation Summary
Changes Made
New file:
crates/hero_livekit_ui/src/whitelist.rs(289 lines) -- Complete IP whitelist module with:Modified files:
crates/hero_livekit_ui/Cargo.toml-- Added ipnetwork = "0.20" dependency for CIDR parsingcrates/hero_livekit_ui/src/main.rs-- Added mod whitelist declaration, WhitelistState initialization on startup, background refresh task spawn, PUT /admin/whitelist route, Extension and middleware layers on Router (whitelist_middleware as outermost layer)Behavior
Test Results
All 34 tests pass, 0 failures.
Pull request opened: #20
This PR implements the changes discussed in this issue.