@easy-cms/core 0.37.1 → 0.37.2
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/dist/index.js +12 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7626,7 +7626,7 @@ async function widgets(cms, user) {
|
|
|
7626
7626
|
}
|
|
7627
7627
|
|
|
7628
7628
|
// src/version.ts
|
|
7629
|
-
var VERSION = true ? "0.37.
|
|
7629
|
+
var VERSION = true ? "0.37.2" : "0.0.0-dev";
|
|
7630
7630
|
|
|
7631
7631
|
// src/rest/admin-status.ts
|
|
7632
7632
|
var DAY2 = 864e5;
|
|
@@ -8584,12 +8584,22 @@ function readCookie(request, name) {
|
|
|
8584
8584
|
}
|
|
8585
8585
|
return void 0;
|
|
8586
8586
|
}
|
|
8587
|
+
function sameHost(origin, request) {
|
|
8588
|
+
let host;
|
|
8589
|
+
try {
|
|
8590
|
+
host = new URL(origin).host;
|
|
8591
|
+
} catch {
|
|
8592
|
+
return false;
|
|
8593
|
+
}
|
|
8594
|
+
const forwarded = request.headers.get("x-forwarded-host")?.split(",")[0]?.trim();
|
|
8595
|
+
return host === (forwarded || request.headers.get("host"));
|
|
8596
|
+
}
|
|
8587
8597
|
function checkCsrf(cms, ctx) {
|
|
8588
8598
|
const origin = ctx.request.headers.get("origin");
|
|
8589
8599
|
const fetchSite = ctx.request.headers.get("sec-fetch-site");
|
|
8590
8600
|
const cookie2 = ctx.via === "cookie" && ctx.token !== void 0;
|
|
8591
8601
|
const { cors } = cms.config;
|
|
8592
|
-
const trusted = origin !== null && (origin === ctx.url.origin || cms.config.auth.trustedOrigins.includes(origin) || !cookie2 && (cors === "*" || cors.includes(origin)));
|
|
8602
|
+
const trusted = origin !== null && (origin === ctx.url.origin || sameHost(origin, ctx.request) || cms.config.auth.trustedOrigins.includes(origin) || !cookie2 && (cors === "*" || cors.includes(origin)));
|
|
8593
8603
|
if (origin !== null && !trusted) throw new ForbiddenError("CSRF check failed: untrusted origin");
|
|
8594
8604
|
if (origin === null && fetchSite === "cross-site")
|
|
8595
8605
|
throw new ForbiddenError("CSRF check failed: cross-site request");
|