mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 17:46:28 +08:00
core: fix csrf
This commit is contained in:
1 parent
92b2535b89
commit
fc98c61f7b
2 files changed
+5
-5
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.24.18",
|
"version": "2.24.19",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -482,10 +482,6 @@ export class Handler extends HandlerCommon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async init({ domainId }) {
|
async init({ domainId }) {
|
||||||
if (this.request.headers.referer) {
|
|
||||||
const hostname = new URL(this.request.headers.referer).hostname;
|
|
||||||
if (hostname !== this.request.hostname) throw new CsrfTokenError();
|
|
||||||
}
|
|
||||||
if (!argv.benchmark) await this.limitRate('global', 10, 88);
|
if (!argv.benchmark) await this.limitRate('global', 10, 88);
|
||||||
const [absoluteDomain, inferDomain, bdoc] = await Promise.all([
|
const [absoluteDomain, inferDomain, bdoc] = await Promise.all([
|
||||||
domain.get(domainId),
|
domain.get(domainId),
|
||||||
@@ -524,6 +520,10 @@ export class Handler extends HandlerCommon {
|
|||||||
text: global.Hydro.lib[key].text,
|
text: global.Hydro.lib[key].text,
|
||||||
}));
|
}));
|
||||||
if (!this.noCheckPermView) this.checkPerm(PERM.PERM_VIEW);
|
if (!this.noCheckPermView) this.checkPerm(PERM.PERM_VIEW);
|
||||||
|
if (this.request.method === 'POST' && this.request.headers.referer) {
|
||||||
|
const hostname = new URL(this.request.headers.referer).hostname;
|
||||||
|
if (hostname !== this.request.hostname) throw new CsrfTokenError(hostname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async finish() {
|
async finish() {
|
||||||
|
|||||||
Reference in new issue
Block a user