v1.6.1: Sicherheit – Rate Limiting, Default-PW via Env, AUTH_SECRET Pflicht, Bcrypt 12

This commit is contained in:
2026-05-11 13:26:51 +02:00
parent 0ea960259c
commit 9bea0a11de
33 changed files with 991 additions and 13 deletions
+14
View File
@@ -1,13 +1,27 @@
'use server';
import { headers } from 'next/headers';
import { redirect } from 'next/navigation';
import { verifyCredentials, getBeoDisplayName } from '@/lib/auth';
import { createSession } from '@/lib/session';
import { checkRateLimit } from '@/lib/ratelimit';
export async function login(
_prevState: { error: string } | undefined,
formData: FormData
): Promise<{ error: string }> {
const headersList = await headers();
const ip =
headersList.get('x-forwarded-for')?.split(',')[0].trim() ??
headersList.get('x-real-ip') ??
'unknown';
const { allowed, remainingMs } = checkRateLimit(ip);
if (!allowed) {
const minutes = Math.ceil(remainingMs / 60000);
return { error: `Zu viele Anmeldeversuche. Bitte ${minutes} Minute${minutes !== 1 ? 'n' : ''} warten.` };
}
const login = (formData.get('username') as string)?.trim();
const password = formData.get('password') as string;