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
+20
View File
@@ -570,6 +570,19 @@ paths:
schema:
$ref: "#/components/schemas/AuthMode"
/auth/csrf:
get:
operationId: getCsrfToken
tags: [auth]
summary: Get a CSRF token for state-changing requests
responses:
"200":
description: CSRF token
content:
application/json:
schema:
$ref: "#/components/schemas/CsrfToken"
/auth/login:
post:
operationId: localLogin
@@ -942,6 +955,13 @@ components:
type: string
enum: [oidc, local]
CsrfToken:
type: object
required: [token]
properties:
token:
type: string
LocalLoginInput:
type: object
required: [username, password]