mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 04:38:28 +00:00
Require CSRF token for debug log generation
This commit is contained in:
@@ -29,6 +29,7 @@ function eventsource() {
|
||||
var ta = $("#output");
|
||||
var upload = $( "#upload" );
|
||||
var checked = "";
|
||||
var token = encodeURIComponent($("#token").html());
|
||||
|
||||
if(upload.prop("checked"))
|
||||
{
|
||||
@@ -37,12 +38,12 @@ function eventsource() {
|
||||
|
||||
// IE does not support EventSource - load whole content at once
|
||||
if (typeof EventSource !== "function") {
|
||||
httpGet(ta,"/admin/scripts/pi-hole/php/debug.php?IE&"+checked);
|
||||
httpGet(ta,"/admin/scripts/pi-hole/php/debug.php?IE&token="+token+"&"+checked);
|
||||
return;
|
||||
}
|
||||
|
||||
var host = window.location.host;
|
||||
var source = new EventSource("/admin/scripts/pi-hole/php/debug.php?"+checked);
|
||||
var source = new EventSource("/admin/scripts/pi-hole/php/debug.php?&token="+token+"&"+checked);
|
||||
|
||||
// Reset and show field
|
||||
ta.empty();
|
||||
|
||||
@@ -5,6 +5,18 @@ ob_implicit_flush(true);
|
||||
header('Content-Type: text/event-stream');
|
||||
header('Cache-Control: no-cache');
|
||||
|
||||
require "password.php";
|
||||
require "auth.php";
|
||||
|
||||
if(!$auth) {
|
||||
die("Unauthorized");
|
||||
}
|
||||
|
||||
check_cors();
|
||||
|
||||
$token = isset($_GET["token"]) ? $_GET["token"] : "";
|
||||
check_csrf($token);
|
||||
|
||||
function echoEvent($datatext) {
|
||||
if(!isset($_GET["IE"]))
|
||||
echo "data: ".implode("\ndata: ", explode("\n", $datatext))."\n\n";
|
||||
|
||||
Reference in New Issue
Block a user