feat(security): add CSRF protection for all state-changing API routes
Build & Push Docker Image / build (push) Successful in 2m16s

- Synchronizer token stored in session; GET /auth/csrf to obtain it
- csrfProtection middleware requires X-CSRF-Token on non-safe methods
- customFetch injects the header via setCsrfTokenGetter
- toolrate boot loads token; reload after local login (session regenerate)
- OpenAPI GET /auth/csrf + CsrfToken schema, orval regenerated
This commit is contained in:
opencode
2026-08-03 10:30:13 +02:00
parent f851305d78
commit bcae59626f
15 changed files with 209 additions and 1 deletions
+8
View File
@@ -445,6 +445,14 @@ export const GetAuthModeResponse = zod.object({
})
/**
* @summary Get a CSRF token for state-changing requests
*/
export const GetCsrfTokenResponse = zod.object({
"token": zod.string()
})
/**
* @summary Local username/password login
*/
@@ -0,0 +1,11 @@
/**
* Generated by orval v8.9.1 🍺
* Do not edit manually.
* Api
* ToolRate API — Tool listing and rating platform
* OpenAPI spec version: 0.1.0
*/
export interface CsrfToken {
token: string;
}
+1
View File
@@ -15,6 +15,7 @@ export * from './authUserRole';
export * from './authUserTier';
export * from './categoryStats';
export * from './changePasswordInput';
export * from './csrfToken';
export * from './emptyTrash200';
export * from './errorResponse';
export * from './getRatingDistributionParams';