From 5c73adfaea3dd9f05d068da7be941fa64daa6510 Mon Sep 17 00:00:00 2001 From: whit3rabbit Date: Sun, 29 Mar 2026 18:08:34 -0500 Subject: [PATCH] feat(admin): team-focused UI overhaul with key editing and audit log Backend: - PUT /admin/api/keys/{id}: update virtual key fields (role immutable), refreshes DashMap, emits key_updated audit entry - update_virtual_key(): resets spend period when budget_duration changes - query_audit_log(): action, target_type, since, until filter params - query_request_log(): add until filter param; wire through RequestsQuery - GET /admin/api/metrics: include streaming counters (started/completed/failed/disconnected) - GET /admin/api/env: include RATE_LIMIT_FAIL_POLICY UI: - Dashboard: streaming metrics stat row - Request Log: key filter dropdown, since/until date pickers, Key column - Access Control tab: allowed_models tag input, edit modal, budget progress bars, key prefix link navigates to filtered request log - Settings: override badges from overridden_keys, Security section (IP allowlist, rate limit fail policy) - Audit tab: action/target/date filters, paginated table Tests: - 7 unit tests for update_virtual_key and query_audit_log filters - 4 integration tests for PUT /admin/api/keys/{id} lifecycle Co-Authored-By: Claude Opus 4.6 --- crates/proxy/admin-ui/index.html | 470 ++++++++++++++++++++-- crates/proxy/src/admin/db.rs | 303 ++++++++++++-- crates/proxy/src/admin/routes.rs | 166 +++++++- crates/proxy/src/integrations/langfuse.rs | 2 +- crates/proxy/src/main.rs | 5 +- crates/proxy/src/server/middleware.rs | 21 + crates/proxy/tests/virtual_keys.rs | 178 ++++++++ 7 files changed, 1082 insertions(+), 63 deletions(-) diff --git a/crates/proxy/admin-ui/index.html b/crates/proxy/admin-ui/index.html index 2930717..4c24fa4 100644 --- a/crates/proxy/admin-ui/index.html +++ b/crates/proxy/admin-ui/index.html @@ -78,6 +78,21 @@ input:focus,select:focus{outline:none;border-color:#4a9eff} .btn-sm{padding:3px 8px;font-size:11px;border-radius:4px} .key-result{background:#0d1117;border:1px solid #3fb950;border-radius:6px;padding:12px;margin-bottom:12px;font-family:monospace;font-size:12px;word-break:break-all} .key-result-label{color:#3fb950;font-size:11px;margin-bottom:4px;font-weight:600} +/* Budget progress bar */ +.budget-bar{height:6px;border-radius:3px;background:#30363d;margin-top:4px;overflow:hidden;min-width:60px} +.budget-bar-fill{height:100%;border-radius:3px;background:#3fb950;transition:width 0.3s} +.budget-bar-fill.warn{background:#d29922}.budget-bar-fill.danger{background:#f85149} +/* Tag chips (allowed_models) */ +.tag-input-area{display:flex;flex-wrap:wrap;gap:4px;padding:4px;background:#0d1117;border:1px solid #30363d;border-radius:4px;min-height:34px;align-items:center;cursor:text} +.tag-input-area:focus-within{border-color:#4a9eff} +.chip{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;background:rgba(74,158,255,0.15);border:1px solid rgba(74,158,255,0.3);border-radius:12px;font-size:11px;color:#4a9eff} +.chip-remove{cursor:pointer;color:#8b949e;font-size:13px;line-height:1} +.chip-remove:hover{color:#f85149} +.tag-input-bare{background:none;border:none;outline:none;color:#c9d1d9;font-size:13px;min-width:80px;padding:2px 4px;flex:1} +/* Modal overlay */ +.modal-backdrop{position:fixed;inset:0;background:rgba(0,0,0,0.6);display:flex;align-items:center;justify-content:center;z-index:100} +.modal{background:#161b22;border:1px solid #30363d;border-radius:8px;padding:20px;width:460px;max-width:95vw;max-height:90vh;overflow-y:auto} +.modal-title{font-weight:600;font-size:15px;margin-bottom:16px;color:#c9d1d9} @@ -96,8 +111,9 @@ input:focus,select:focus{outline:none;border-color:#4a9eff} - + + @@ -109,6 +125,12 @@ input:focus,select:focus{outline:none;border-color:#4a9eff}
P95 Latency
--
Total Requests
0
+
+
Streams Started
0
+
Completed
0
+
Failed
0
+
Client Disconnects
0
+
@@ -125,14 +147,17 @@ input:focus,select:focus{outline:none;border-color:#4a9eff}
-
+
+ + +
-
Time
Status
Backend
Model
Latency
In
Out
+
Time
Status
Backend
Key
Model
Latency
In
Out
+ +
Loading...
@@ -243,6 +308,39 @@ input:focus,select:focus{outline:none;border-color:#4a9eff}
+
+
+ +
+ + + + + +
+
+
+
+
Loading...
+
+
+ +
+