adminizer 4.3.0-build.140 → 4.3.0-build.141
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/inertia/inertiaAdapter.js +10 -11
- package/package.json +1 -1
|
@@ -11,17 +11,16 @@ const inertiaExpressAdapter = function ({ version, html, flashMessages, enableRe
|
|
|
11
11
|
}) {
|
|
12
12
|
return (req, res, next) => {
|
|
13
13
|
if (csrf.enabled) {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
if (!isApiRoute) {
|
|
14
|
+
const isApiRoute = isApiRequest(req);
|
|
15
|
+
if (!isApiRoute) {
|
|
16
|
+
const csrfToken = randomBytes(32).toString('hex');
|
|
17
|
+
res.cookie('XSRF-TOKEN', csrfToken, {
|
|
18
|
+
httpOnly: false,
|
|
19
|
+
secure: process.env.NODE_ENV === 'production' && process.env.CSRF_COOKIE_INSECURE !== '1',
|
|
20
|
+
sameSite: 'lax',
|
|
21
|
+
});
|
|
22
|
+
// Проверяем CSRF только для не-GET запросов И не-API routes
|
|
23
|
+
if (!['GET', 'HEAD', 'OPTIONS'].includes(req.method)) {
|
|
25
24
|
const csrfCookie = req.cookies['XSRF-TOKEN'];
|
|
26
25
|
const csrfHeader = req.headers[csrf.headerName || 'x-xsrf-token'];
|
|
27
26
|
if (!csrfCookie || !csrfHeader || csrfCookie !== csrfHeader) {
|