fixed health check

master
Alexander Graf 3 years ago
parent e7e283663d
commit b3d48cc20f
No known key found for this signature in database
GPG Key ID: B8A9DC143E075629

@ -15,7 +15,14 @@ class mailu extends rcube_plugin
function startup($args) function startup($args)
{ {
if (empty($_SESSION['user_id'])) { if (empty($_SESSION['user_id'])) {
$args['action'] = 'login'; $args['action'] = 'login';
}
$ua = $_SERVER['HTTP_USER_AGENT'];
$ra = $_SERVER['REMOTE_ADDR'];
if ($ua == 'health' and ($ra == '127.0.0.1' or $ra == '::1')) {
print('OK');
exit();
} }
return $args; return $args;
@ -24,13 +31,13 @@ class mailu extends rcube_plugin
function authenticate($args) function authenticate($args)
{ {
if (!array_key_exists('HTTP_X_REMOTE_USER', $_SERVER) or !array_key_exists('HTTP_X_REMOTE_USER_TOKEN', $_SERVER)) { if (!array_key_exists('HTTP_X_REMOTE_USER', $_SERVER) or !array_key_exists('HTTP_X_REMOTE_USER_TOKEN', $_SERVER)) {
if ($_SERVER['PHP_SELF'] == '/sso.php') { if ($_SERVER['PHP_SELF'] == '/sso.php') {
header('HTTP/1.0 403 Forbidden'); header('HTTP/1.0 403 Forbidden');
print('mailu sso failure'); print('mailu sso failure');
} else { } else {
header('Location: sso.php'); header('Location: sso.php');
} }
exit(); exit();
} }
$args['user'] = $_SERVER['HTTP_X_REMOTE_USER']; $args['user'] = $_SERVER['HTTP_X_REMOTE_USER'];
@ -53,20 +60,14 @@ class mailu extends rcube_plugin
function login($args) function login($args)
{ {
header('Location: index.php'); header('Location: index.php');
exit(); exit();
} }
function login_failed($args) function login_failed($args)
{ {
$ua = $_SERVER['HTTP_USER_AGENT']; header('Location: sso.php');
$ra = $_SERVER['REMOTE_ADDR']; exit();
if ($ua == 'health' and ($ra == '127.0.0.1' or $ra == '::1')) {
print('OK');
} else {
header('Location: sso.php');
}
exit();
} }
} }

Loading…
Cancel
Save