feat: implement comprehensive CSRF protection

This commit is contained in:
2025-07-11 18:06:51 +02:00
committed by Kaj Kowalski
parent e7818f5e4f
commit 3e9e75e854
44 changed files with 14964 additions and 6413 deletions

View File

@ -0,0 +1,19 @@
/**
* CSRF Token API Endpoint
*
* This endpoint provides CSRF tokens to clients for secure form submissions.
* It generates a new token and sets it as an HTTP-only cookie.
*/
import { NextRequest } from "next/server";
import { generateCSRFTokenResponse } from "../../../middleware/csrfProtection";
/**
* GET /api/csrf-token
*
* Generates and returns a new CSRF token.
* The token is also set as an HTTP-only cookie for automatic inclusion in requests.
*/
export function GET(request: NextRequest) {
return generateCSRFTokenResponse();
}

View File

@ -75,8 +75,8 @@ export async function POST(
);
} else {
return NextResponse.json(
{
error: `Email already in use by a user in company: ${existingUser.company.name}. Each email address can only be used once across all companies.`
{
error: `Email already in use by a user in company: ${existingUser.company.name}. Each email address can only be used once across all companies.`
},
{ status: 400 }
);