mirror of
https://github.com/pi-hole/web.git
synced 2026-04-24 10:50:23 +01:00
Check if the API call was made using authentication
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
This commit is contained in:
@@ -26,7 +26,7 @@ if (isset($setupVars['WEBPASSWORD'])) {
|
||||
$pwhash = '';
|
||||
}
|
||||
|
||||
function verifyPassword($pwhash)
|
||||
function verifyPassword($pwhash, $use_api = false)
|
||||
{
|
||||
$validpassword = true;
|
||||
|
||||
@@ -86,7 +86,7 @@ function verifyPassword($pwhash)
|
||||
if (hash_equals($pwhash, $_SESSION['hash'])) {
|
||||
$_SESSION['auth'] = true;
|
||||
}
|
||||
} elseif (isset($api) && isset($_GET['auth'])) {
|
||||
} elseif ($use_api && isset($_GET['auth'])) {
|
||||
// API can use the hash to get data without logging in via plain-text password
|
||||
if (hash_equals($pwhash, $_GET['auth'])) {
|
||||
$_SESSION['auth'] = true;
|
||||
@@ -103,5 +103,5 @@ function verifyPassword($pwhash)
|
||||
return $validpassword;
|
||||
}
|
||||
|
||||
$wrongpassword = !verifyPassword($pwhash);
|
||||
$wrongpassword = !verifyPassword($pwhash, isset($api));
|
||||
$auth = $_SESSION['auth'];
|
||||
|
||||
Reference in New Issue
Block a user