M3 Integration fixes

This commit is contained in:
Mark Gregory
2026-09-21 13:33:05 +01:00
parent 3521e47ef0
commit 66aeefbba5
23 changed files with 674 additions and 691 deletions
+15 -15
View File
@@ -27,26 +27,26 @@ class BasicAuth
}
$handle = fopen($passwordFile, 'rb');
if ($handle === false) {
return false;
}
$valid = false;
try {
while (($line = fgets($handle)) !== false) {
$parts = explode(':', trim($line), 2);
if (count($parts) !== 2 || ! hash_equals($parts[0], $login)) {
continue;
if ($handle !== false) {
try {
while (($line = fgets($handle)) !== false) {
$parts = explode(':', trim($line), 2);
if (count($parts) !== 2 || ! hash_equals($parts[0], $login)) {
continue;
}
$storedHash = trim($parts[1]);
$valid = $storedHash !== '' && password_verify($password, $storedHash);
break;
}
$storedHash = trim($parts[1]);
return $storedHash !== '' && password_verify($password, $storedHash);
} finally {
fclose($handle);
}
} finally {
fclose($handle);
}
return false;
return $valid;
}
private function unauthorized(): Response