diff --git a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/httpserver.xml b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/httpserver.xml index 50282f3d5..9c57cbc97 100644 --- a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/httpserver.xml +++ b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/httpserver.xml @@ -131,6 +131,12 @@ If you select an IP ACL, the client can only access this service if it fulfills this requirement. + + httpserver.advanced_acl_server + + dropdown + Choose a backend for advanced authentication. If you don't have one, configure it under System -> Access -> Servers. If nothing is configured, the local database is used. + httpserver.satisfy diff --git a/www/nginx/src/opnsense/mvc/app/models/OPNsense/Nginx/Nginx.xml b/www/nginx/src/opnsense/mvc/app/models/OPNsense/Nginx/Nginx.xml index debdd96e8..a1be30e1a 100644 --- a/www/nginx/src/opnsense/mvc/app/models/OPNsense/Nginx/Nginx.xml +++ b/www/nginx/src/opnsense/mvc/app/models/OPNsense/Nginx/Nginx.xml @@ -690,6 +690,11 @@ N N + + N + N + Local Database + Any diff --git a/www/nginx/src/opnsense/scripts/nginx/ngx_auth.php b/www/nginx/src/opnsense/scripts/nginx/ngx_auth.php index 8927f9b86..2b1a52aba 100644 --- a/www/nginx/src/opnsense/scripts/nginx/ngx_auth.php +++ b/www/nginx/src/opnsense/scripts/nginx/ngx_auth.php @@ -45,13 +45,19 @@ function password_auth_test($username, $password, $auth_server) function password_auth($auth_server = 'Local Database') { - if (!isset($_SERVER['PHP_AUTH_PW']) || !isset($_SERVER['PHP_AUTH_PW'])) { + if (!isset($_SERVER['PHP_AUTH_PW']) || !isset($_SERVER['PHP_AUTH_USER'])) { return false; } return password_auth_test($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'], $auth_server); } -if (password_auth()) { +if (empty($_SERVER['AUTH_SERVER'])) { + $auth_server = 'Local Database'; +} else { + $auth_server = $_SERVER['AUTH_SERVER']; +} + +if (password_auth($auth_server)) { header("HTTP/1.1 200 OK"); } else { header("HTTP/1.1 401 Authorization Required"); diff --git a/www/nginx/src/opnsense/service/templates/OPNsense/Nginx/http.conf b/www/nginx/src/opnsense/service/templates/OPNsense/Nginx/http.conf index 0aa7dbd67..7d66d1af3 100644 --- a/www/nginx/src/opnsense/service/templates/OPNsense/Nginx/http.conf +++ b/www/nginx/src/opnsense/service/templates/OPNsense/Nginx/http.conf @@ -184,13 +184,7 @@ server { fastcgi_param TLS-Cipher $ssl_cipher; fastcgi_param TLS-Protocol $ssl_protocol; fastcgi_param TLS-SNI-Host $ssl_server_name; -{% if helpers._template_in_data['__uuid__'] is defined %} -{% for uuid in helpers._template_in_data['__uuid__'] %} -{% if helpers._template_in_data['__uuid__'][uuid] == server %} - fastcgi_param SERVER-UUID "{{ uuid }}"; -{% endif %} -{% endfor %} -{% endif %} + fastcgi_param SERVER-UUID "{{ server['@uuid'] }}"; fastcgi_intercept_errors on; fastcgi_pass unix:/var/run/php-webgui.socket; } @@ -205,6 +199,9 @@ server { fastcgi_param Original-HOST $host; fastcgi_param SERVER-UUID "{{ server['@uuid'] }}"; fastcgi_param SCRIPT_FILENAME /usr/local/opnsense/scripts/nginx/ngx_auth.php; +{% if server.advanced_acl_server is defined and server.advanced_acl_server != '' %} + fastcgi_param AUTH_SERVER "{{ server.advanced_acl_server.replace("\\", "\\\\").replace("$", "\\$").replace("\"", "\\\"") }}"; +{% endif %} fastcgi_intercept_errors on; include fastcgi_params; }