From 02fd4f4c7f216cbd4b2d65fd725cc3e232c32c2c Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Thu, 28 Feb 2019 09:57:54 +0100 Subject: [PATCH] Web proxy, switch to PAM, closes https://github.com/opnsense/core/issues/3261 --- plist | 1 - src/etc/inc/plugins.inc.d/squid/auth-user.php | 87 ------------------- .../OPNsense/Proxy/squid.user.local_auth.conf | 2 +- 3 files changed, 1 insertion(+), 89 deletions(-) delete mode 100755 src/etc/inc/plugins.inc.d/squid/auth-user.php diff --git a/plist b/plist index f605e33f1..ae843d9b5 100644 --- a/plist +++ b/plist @@ -41,7 +41,6 @@ /usr/local/etc/inc/plugins.inc.d/openvpn/wizard.inc /usr/local/etc/inc/plugins.inc.d/pf.inc /usr/local/etc/inc/plugins.inc.d/squid.inc -/usr/local/etc/inc/plugins.inc.d/squid/auth-user.php /usr/local/etc/inc/plugins.inc.d/suricata.inc /usr/local/etc/inc/plugins.inc.d/unbound.inc /usr/local/etc/inc/plugins.inc.d/unbound/root.min.hints diff --git a/src/etc/inc/plugins.inc.d/squid/auth-user.php b/src/etc/inc/plugins.inc.d/squid/auth-user.php deleted file mode 100755 index 0be92963e..000000000 --- a/src/etc/inc/plugins.inc.d/squid/auth-user.php +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/local/bin/php -get(trim($authServerName)); - if ($authServer == null) { - // authenticator not found, use local - $authServer = $authFactory->get('Local Database'); - } - $isAuthenticated = $authServer->authenticate($username, $password); - if ($isAuthenticated) { - if (get_class($authServer) == "OPNsense\Auth\Local") { - // todo: user priv check needs a reload of squid, maybe it's better to move the token check to - // the auth object. - // - // when using local authentication, check if user has role user-proxy-auth - $user = getUserEntry($username); - if (is_array($user) && userHasPrivilege($user, "user-proxy-auth")) { - break; - } else { - // log user auth failure - syslog(LOG_WARNING, "user '{$username}' cannot authenticate for squid because of missing user-proxy-auth role"); - fwrite(STDOUT, "ERR\n"); - $isAuthenticated = false; - } - } else { - break; - } - } - } - } - - if ($isAuthenticated) { - syslog(LOG_NOTICE, "user '{$username}' authenticated\n"); - fwrite(STDOUT, "OK\n"); - } else { - syslog(LOG_WARNING, "user '{$username}' could not authenticate.\n"); - fwrite(STDOUT, "ERR\n"); - } - } -} - -closelog(); diff --git a/src/opnsense/service/templates/OPNsense/Proxy/squid.user.local_auth.conf b/src/opnsense/service/templates/OPNsense/Proxy/squid.user.local_auth.conf index 6800f79e1..7cd8e8c5a 100644 --- a/src/opnsense/service/templates/OPNsense/Proxy/squid.user.local_auth.conf +++ b/src/opnsense/service/templates/OPNsense/Proxy/squid.user.local_auth.conf @@ -1,5 +1,5 @@ # Configure Local User Authentication helper -auth_param basic program /usr/local/etc/inc/plugins.inc.d/squid/auth-user.php +auth_param basic program /usr/local/libexec/squid/basic_pam_auth -o {% if helpers.exists('OPNsense.proxy.forward.authentication.realm') %} auth_param basic realm {{OPNsense.proxy.forward.authentication.realm}} {% endif %}