add loger, access log and bans/whitelist
This commit is contained in:
@@ -12,6 +12,22 @@
|
||||
|
||||
<!-- Settings Sections -->
|
||||
<div class="space-y-8">
|
||||
<!-- Quick Actions -->
|
||||
<div class="bg-gray-800 rounded-lg p-6">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h2 class="text-xl font-semibold text-white mb-1">
|
||||
<i class="fas fa-tools mr-2"></i>Admin Tools
|
||||
</h2>
|
||||
<p class="text-gray-400">Access logs and security controls</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<a href="/editor/admin/logs" target="_blank" class="btn-secondary inline-flex items-center">
|
||||
<i class="fas fa-list mr-2"></i>View Logs
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Image Storage Settings -->
|
||||
<div class="bg-gray-800 rounded-lg p-6">
|
||||
<h2 class="text-xl font-semibold text-white mb-4">
|
||||
@@ -170,6 +186,58 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Security Settings -->
|
||||
<div class="bg-gray-800 rounded-lg p-6">
|
||||
<h2 class="text-xl font-semibold text-white mb-4">
|
||||
<i class="fas fa-shield-alt mr-2"></i>Security (IP Ban & Thresholds)
|
||||
</h2>
|
||||
<p class="text-gray-400 mb-6">Configure failed login thresholds, window, and automatic ban behavior</p>
|
||||
|
||||
<form id="security-settings-form" class="space-y-6">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label for="pwd_failures_threshold" class="block text-sm font-medium text-gray-300 mb-2">Password Failures Threshold</label>
|
||||
<input type="number" id="pwd_failures_threshold" name="pwd_failures_threshold" min="1"
|
||||
class="w-full bg-gray-700 border border-gray-600 rounded-lg px-4 py-2 text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
||||
placeholder="e.g., 5">
|
||||
</div>
|
||||
<div>
|
||||
<label for="mfa_failures_threshold" class="block text-sm font-medium text-gray-300 mb-2">MFA Failures Threshold</label>
|
||||
<input type="number" id="mfa_failures_threshold" name="mfa_failures_threshold" min="1"
|
||||
class="w-full bg-gray-700 border border-gray-600 rounded-lg px-4 py-2 text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
||||
placeholder="e.g., 10">
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label for="failures_window_minutes" class="block text-sm font-medium text-gray-300 mb-2">Failures Window (minutes)</label>
|
||||
<input type="number" id="failures_window_minutes" name="failures_window_minutes" min="1"
|
||||
class="w-full bg-gray-700 border border-gray-600 rounded-lg px-4 py-2 text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
||||
placeholder="e.g., 30">
|
||||
</div>
|
||||
<div>
|
||||
<label for="auto_ban_duration_hours" class="block text-sm font-medium text-gray-300 mb-2">Auto-ban Duration (hours)</label>
|
||||
<input type="number" id="auto_ban_duration_hours" name="auto_ban_duration_hours" min="1"
|
||||
class="w-full bg-gray-700 border border-gray-600 rounded-lg px-4 py-2 text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
||||
placeholder="e.g., 12">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="flex items-center space-x-2">
|
||||
<input type="checkbox" id="auto_ban_permanent" name="auto_ban_permanent" class="h-4 w-4 text-blue-600 rounded border-gray-600 bg-gray-700">
|
||||
<span class="text-sm text-gray-300">Make auto-bans permanent</span>
|
||||
</label>
|
||||
<p class="text-xs text-gray-500 mt-1">If enabled, IPs exceeding thresholds are permanently banned instead of temporary bans.</p>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end">
|
||||
<button type="submit" class="btn-primary">
|
||||
<i class="fas fa-save mr-2"></i>Save Security Settings
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
@@ -213,6 +281,18 @@
|
||||
document.getElementById('show_files_in_folder').checked = !!data.show_files_in_folder;
|
||||
})
|
||||
.catch(error => console.error('Error loading file extensions settings:', error));
|
||||
|
||||
// Load security settings
|
||||
fetch('/editor/settings/security')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
document.getElementById('pwd_failures_threshold').value = data.pwd_failures_threshold ?? '';
|
||||
document.getElementById('mfa_failures_threshold').value = data.mfa_failures_threshold ?? '';
|
||||
document.getElementById('failures_window_minutes').value = data.failures_window_minutes ?? '';
|
||||
document.getElementById('auto_ban_duration_hours').value = data.auto_ban_duration_hours ?? '';
|
||||
document.getElementById('auto_ban_permanent').checked = !!data.auto_ban_permanent;
|
||||
})
|
||||
.catch(error => console.error('Error loading security settings:', error));
|
||||
}
|
||||
|
||||
// Toggle storage mode options
|
||||
@@ -232,6 +312,34 @@
|
||||
}
|
||||
});
|
||||
|
||||
// Security settings form
|
||||
document.getElementById('security-settings-form').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const formData = new FormData(this);
|
||||
// Normalize checkbox to boolean string
|
||||
formData.set('auto_ban_permanent', document.getElementById('auto_ban_permanent').checked ? 'true' : 'false');
|
||||
|
||||
const csrf = (document.cookie.match(/(?:^|; )csrf_token=([^;]+)/)||[])[1] ? decodeURIComponent((document.cookie.match(/(?:^|; )csrf_token=([^;]+)/)||[])[1]) : '';
|
||||
|
||||
fetch('/editor/settings/security', {
|
||||
method: 'POST',
|
||||
headers: csrf ? { 'X-CSRF-Token': csrf } : {},
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
showNotification('Security settings saved successfully', 'success');
|
||||
} else {
|
||||
throw new Error(data.error || 'Failed to save settings');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
showNotification('Error: ' + error.message, 'error');
|
||||
});
|
||||
});
|
||||
|
||||
// Image storage form
|
||||
document.getElementById('image-storage-form').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user