mirror of
https://github.com/sol1/rustguac.git
synced 2026-09-10 09:35:45 +00:00
be3bea8b30
New SQLite table addressbook_audit_log records destructive and mutating actions against the connections tree: create_folder, update_folder, delete_folder, create_entry, update_entry, delete_entry. Each row captures user_email, action, scope, folder_path, optional entry_name, client IP, a small JSON details blob, and created_at. Details is deliberately headline-only: counts for delete_folder (subfolders_deleted, entries_deleted), allowed_groups_count + inherit_from_parent for folder writes, session type for entry writes. Entry field values (password, private_key, hostname) and full request bodies are never written. Audit rows live in SQLite, not Vault, so logging content would leak Vault-only secrets onto disk. The six handlers in api.rs gain ConnectInfo + HeaderMap + TrustedProxies + Db extractors so client IP can be resolved through the existing auth::client_ip helper (respecting trusted proxies) and the audit row can be written post-success. New admin-only endpoint GET /api/admin/addressbook-audit mirrors the existing token audit shape (limit + email filter, capped at 1000). admin.html gains a "Connections Audit Log" section below the token audit, auto-loaded on page show. cleanup_old_audit_log now also sweeps the new table on the same retention window as token_audit_log.