feat(auth): enhance security and audit logging

- Integrate webhook alerts for admin login lockouts.
- Implement detailed audit logging for login, logout, and setup actions.
- Improve client revocation event tracking.
- Standardize error handling in profile updates.
- Enforce 'operator' role for event API access.
This commit is contained in:
Team Dark Devil committed 2026-11-21 00:06:55 +06:00
1 parent 5c977d6977
commit 8132087085
52 files changed
+4434 -407

No files matched your search

+12
View File
@@ -10,6 +10,7 @@ import {
clearAdminLoginAttempts,
consumeAdminLoginAttempt,
} from "@/core/auth/adminUsers";
import { SettingsManager } from "@/core/adminSettings/settingsManager";
import { recordAdminAuditLogAsync } from "@/core/auth/auditLog";
import { extractClientIp } from "@/lib/adminAuth";
import { NextRequest, NextResponse } from "next/server";
@@ -70,6 +71,17 @@ export async function POST(request: NextRequest) {
);
}
if (!throttleDecision.allowed) {
SettingsManager.triggerWebhookAlert({
event: "ADMIN_LOGIN_LOCKOUT",
severity: "warning",
title: "Admin Login Lockout Triggered",
message: `Admin sign-in throttled for ${email} from IP ${clientIp} (${throttleDecision.retryAfterSeconds}s lockout).`,
details: {
email,
clientIp,
retryAfterSeconds: throttleDecision.retryAfterSeconds,
},
});
return NextResponse.json(
{ error: "Too many sign-in attempts. Try again later." },
{