Preventing all CSRF

This commit is contained in:
myvesta 2021-08-15 14:53:16 +02:00 committed by GitHub
commit 55c591535c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -49,3 +49,16 @@ if ($skip_login_url_check==0) {
}
}
}
// Preventing all CSRF
if ($skip_login_url_check==0) {
if ($_SERVER['REQUEST_METHOD']=='POST') {
$host_arr=explode(":", $_SERVER['HTTP_HOST']);
$hostname=$host_arr[0];
$port = $_SERVER['SERVER_PORT'];
$expected_http_origin="https://".$hostname.":".$port;
if ($_SERVER['HTTP_ORIGIN'] != $expected_http_origin) {
die ("Nope.");
}
}
}