From c4350a614e12c178ff24db31d515b3cf5acb7232 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 2 Apr 2026 01:22:50 -0400 Subject: [PATCH] Add GUI for editing Agent WL (IP Whitelist) and RL (Rate Limit) - Added Edit modal for existing agents - Can modify IP whitelist (comma-separated, supports CIDR/FQDN) - Can modify rate limits (per minute and per hour) - Shows current values in modal - Cancel/Save workflow with toast notifications - Click outside modal to close The agents.html page now has full CRUD for agent settings: - Create with WL/RL - Edit WL/RL - Lock/Unlock/Revoke --- .../clavis-vault/cmd/clavitor/web/agents.html | 80 ++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/clavis/clavis-vault/cmd/clavitor/web/agents.html b/clavis/clavis-vault/cmd/clavitor/web/agents.html index 4f45a9b..4800f67 100644 --- a/clavis/clavis-vault/cmd/clavitor/web/agents.html +++ b/clavis/clavis-vault/cmd/clavitor/web/agents.html @@ -71,6 +71,43 @@

Loading...

+ + + @@ -139,7 +176,8 @@ '' + escapeHtml(a.last_ip) + '' + '' + a.rate_limit_minute + '/m ' + a.rate_limit_hour + '/h' + '' + escapeHtml(ips) + '' + - ''; + '' + + ' '; if (a.status === 'locked') { html += ''; @@ -257,6 +295,46 @@ loadAgents(); }); + // Edit modal functions + function openEditModal(id, name, ips, rateMin, rateHour) { + document.getElementById('editAgentId').value = id; + document.getElementById('editAgentNameDisplay').textContent = name; + document.getElementById('editAgentIPs').value = ips || ''; + document.getElementById('editRateMin').value = rateMin || 5; + document.getElementById('editRateHour').value = rateHour || 10; + document.getElementById('editModal').classList.remove('hidden'); + } + + function closeEditModal() { + document.getElementById('editModal').classList.add('hidden'); + } + + async function saveAgentSettings() { + var id = document.getElementById('editAgentId').value; + var ipsStr = document.getElementById('editAgentIPs').value.trim(); + var ips = ipsStr ? ipsStr.split(',').map(function(s) { return s.trim(); }).filter(Boolean) : []; + + var data = { + ip_whitelist: ips, + rate_limit_minute: parseInt(document.getElementById('editRateMin').value) || 5, + rate_limit_hour: parseInt(document.getElementById('editRateHour').value) || 10 + }; + + try { + await api('PUT', '/api/agents/' + id, data); + toast('Agent settings updated'); + closeEditModal(); + loadAgents(); + } catch(e) { + toast('Failed to update agent: ' + e.message, 'error'); + } + } + + // Close modal on outside click + document.getElementById('editModal').addEventListener('click', function(e) { + if (e.target === this) closeEditModal(); + }); + // Stateless: check sessionStorage for master key if (!getL1Bearer()) { window.location.href = '/app/';