mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2026-07-29 16:13:39 +00:00
[Web] Add sogo_auth_internal nginx marker for sogo-auth.php
This commit is contained in:
@@ -42,6 +42,11 @@ http {
|
|||||||
https https;
|
https https;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
map $server_port $sogo_auth_internal {
|
||||||
|
65510 "1";
|
||||||
|
default "";
|
||||||
|
}
|
||||||
|
|
||||||
{% if HTTP_REDIRECT %}
|
{% if HTTP_REDIRECT %}
|
||||||
# HTTP to HTTPS redirect
|
# HTTP to HTTPS redirect
|
||||||
server {
|
server {
|
||||||
|
|||||||
@@ -116,6 +116,8 @@ location ~ \.php$ {
|
|||||||
include /etc/nginx/fastcgi_params;
|
include /etc/nginx/fastcgi_params;
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
|
# trusted internal-auth marker; empty for external clients (see nginx.conf map)
|
||||||
|
fastcgi_param SOGO_AUTH_INTERNAL $sogo_auth_internal;
|
||||||
fastcgi_read_timeout 3600;
|
fastcgi_read_timeout 3600;
|
||||||
fastcgi_send_timeout 3600;
|
fastcgi_send_timeout 3600;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,12 @@ $ALLOW_ADMIN_EMAIL_LOGIN = (preg_match(
|
|||||||
$session_var_user_allowed = 'sogo-sso-user-allowed';
|
$session_var_user_allowed = 'sogo-sso-user-allowed';
|
||||||
$session_var_pass = 'sogo-sso-pass';
|
$session_var_pass = 'sogo-sso-pass';
|
||||||
|
|
||||||
|
// only the internal nginx auth_request loopback (127.0.0.1:65510) sets this;
|
||||||
|
// external clients can never supply it (bare fastcgi param, not an HTTP header)
|
||||||
|
$is_internal_auth = (($_SERVER['SOGO_AUTH_INTERNAL'] ?? '') === '1');
|
||||||
|
|
||||||
// validate credentials for basic auth requests
|
// validate credentials for basic auth requests
|
||||||
if (isset($_SERVER['PHP_AUTH_USER'])) {
|
if ($is_internal_auth && isset($_SERVER['PHP_AUTH_USER'])) {
|
||||||
// load prerequisites only when required
|
// load prerequisites only when required
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/prerequisites.inc.php';
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/prerequisites.inc.php';
|
||||||
|
|
||||||
@@ -80,7 +84,7 @@ elseif (isset($_GET['login'])) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
// only check for admin-login on sogo GUI requests
|
// only check for admin-login on sogo GUI requests
|
||||||
elseif (isset($_SERVER['HTTP_X_ORIGINAL_URI']) && strcasecmp(substr($_SERVER['HTTP_X_ORIGINAL_URI'], 0, 9), "/SOGo/so/") === 0) {
|
elseif ($is_internal_auth && isset($_SERVER['HTTP_X_ORIGINAL_URI']) && strcasecmp(substr($_SERVER['HTTP_X_ORIGINAL_URI'], 0, 9), "/SOGo/so/") === 0) {
|
||||||
// this is an nginx auth_request call, we check for existing sogo-sso session variables
|
// this is an nginx auth_request call, we check for existing sogo-sso session variables
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/vars.inc.php';
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/vars.inc.php';
|
||||||
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/inc/vars.local.inc.php')) {
|
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/inc/vars.local.inc.php')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user