Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix query string authentication for API calls #2329

Merged
merged 1 commit into from
Sep 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scripts/pi-hole/php/password.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
$pwhash = '';
}

function verifyPassword($pwhash)
function verifyPassword($pwhash, $use_api = false)
{
$validpassword = true;

Expand Down Expand Up @@ -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;
Expand All @@ -103,5 +103,5 @@ function verifyPassword($pwhash)
return $validpassword;
}

$wrongpassword = !verifyPassword($pwhash);
$wrongpassword = !verifyPassword($pwhash, isset($api));
$auth = $_SESSION['auth'];