Quellcode durchsuchen

fix: repair cli/health.php for OIDC installations (#8040)

* fix: repair cli/health.php for OIDC installations

Connected with #8039
This changes will restore healthcheck process both for classic and OIDC logins

* Finalise fixes

---------

Co-authored-by: alexx_b <alexx_b@mir-lin1.mir.int>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
GreyChame1eon vor 5 Monaten
Ursprung
Commit
715a027abd
1 geänderte Dateien mit 9 neuen und 4 gelöschten Zeilen
  1. 9 4
      cli/health.php

+ 9 - 4
cli/health.php

@@ -4,15 +4,15 @@ declare(strict_types=1);
 
 if (php_sapi_name() !== 'cli') {
 	echo 'Error: This script may only be invoked from command line!', PHP_EOL;
-	die(2);
+	die(3);
 }
 
 $options = getopt('', ['url::', 'connect_timeout::', 'timeout::']);
-$address = is_string($options['url'] ?? null) ? $options['url'] : 'http://localhost/i/';
+$address = is_string($options['url'] ?? null) ? $options['url'] : 'http://localhost/api/';
 $ch = curl_init($address);
 if ($ch === false) {
 	fwrite(STDERR, 'Error: Failed to initialize cURL!' . PHP_EOL);
-	die(3);
+	die(4);
 }
 curl_setopt_array($ch, [
 	CURLOPT_CONNECTTIMEOUT => is_numeric($options['connect_timeout'] ?? null) ? (int)$options['connect_timeout'] : 3,
@@ -26,6 +26,11 @@ curl_setopt_array($ch, [
 $content = curl_exec($ch);
 $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
-if ($httpCode !== 200 || !is_string($content) || !str_contains($content, 'jsonVars') || !str_contains($content, '</html>')) {
+if ($httpCode !== 200 || !is_string($content)) {
 	die(1);
 }
+
+$content = rtrim($content, "\n\r");
+if (!str_starts_with($content, '<!DOCTYPE html>') || !str_ends_with($content, '</html>') || !str_contains($content, '/scripts/api.js')) {
+	die(2);
+}