Implement Phase 2 audit logging

Add audit logging for admin settings changes, rate limit config updates, anomaly detection config changes (skipped due to no UI), and version cleanup settings updates. Implement logging via central logAdminAction helper and integrate into AdminSettings, VersionCleanupSettings, and RateLimitAlerts mutations (create, update, delete).
This commit is contained in:
gpt-engineer-app[bot]
2025-11-11 14:36:10 +00:00
parent 8581950a6e
commit a5fed1e26a
3 changed files with 88 additions and 6 deletions

View File

@@ -68,7 +68,15 @@ export function VersionCleanupSettings() {
const handleSaveRetention = async () => {
setIsSaving(true);
const oldRetentionDays = retentionDays;
try {
// Get current value for audit log
const { data: currentSetting } = await supabase
.from('admin_settings')
.select('setting_value')
.eq('setting_key', 'version_retention_days')
.single();
const { error } = await supabase
.from('admin_settings')
.update({ setting_value: retentionDays.toString() })
@@ -76,6 +84,14 @@ export function VersionCleanupSettings() {
if (error) throw error;
// Log to audit trail
const { logAdminAction } = await import('@/lib/adminActionAuditHelpers');
await logAdminAction('version_cleanup_config_changed', {
setting_key: 'version_retention_days',
old_value: currentSetting?.setting_value,
new_value: retentionDays,
});
toast({
title: 'Settings Saved',
description: 'Retention period updated successfully'