mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
www/web-proxy-useracl: lint, style, whitespaces and menu
This commit is contained in:
@@ -2,4 +2,3 @@
|
||||
if [ -f /var/run/squid/squid.pid ]; then
|
||||
service squid reload
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
PLUGIN_NAME= web-proxy-useracl
|
||||
PLUGIN_VERSION= 0.0.1
|
||||
PLUGIN_COMMENT= Group & User Squid ACL
|
||||
PLUGIN_DEPENDS=
|
||||
PLUGIN_COMMENT= Group and user ACL for the web proxy
|
||||
PLUGIN_MAINTAINER= kekek2@ya.ru
|
||||
PLUGIN_WWW= http://smart-soft.ru
|
||||
PLUGIN_WWW= http://smart-soft.ru
|
||||
PLUGIN_DEVEL= yes
|
||||
|
||||
.include "../../Mk/plugins.mk"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Allow users and group-based policies in the web proxy.
|
||||
+12
-10
@@ -55,11 +55,15 @@ class SettingsController extends ApiMutableModelControllerBase
|
||||
$this->sessionClose();
|
||||
$mdlProxyUserACL = $this->getModel();
|
||||
foreach ($mdlProxyUserACL->general->ACLs->ACL->getNodes() as $uuid => $acl) {
|
||||
$mdlProxyUserACL->general->ACLs->ACL->{$uuid}->Domains = $this->decode($mdlProxyUserACL->general->ACLs->ACL->{$uuid}->Domains);
|
||||
$mdlProxyUserACL->general->ACLs->ACL->{$uuid}->Domains =
|
||||
$this->decode($mdlProxyUserACL->general->ACLs->ACL->{$uuid}->Domains);
|
||||
}
|
||||
$grid = new UIModelGrid($mdlProxyUserACL->general->ACLs->ACL);
|
||||
return $grid->fetchBindRequest($this->request, array("Group", "Name", "Domains", "Black", "Priority", "uuid"),
|
||||
"Priority");
|
||||
return $grid->fetchBindRequest(
|
||||
$this->request,
|
||||
array("Group", "Name", "Domains", "Black", "Priority", "uuid"),
|
||||
"Priority"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +75,6 @@ class SettingsController extends ApiMutableModelControllerBase
|
||||
{
|
||||
$result = array("result" => "failed");
|
||||
if ($this->request->isPost() && $this->request->hasPost("ACL")) {
|
||||
|
||||
$result = array("result" => "failed", "validations" => array());
|
||||
$mdlProxyUserACL = $this->getModel();
|
||||
$post = $this->request->getPost("ACL");
|
||||
@@ -104,7 +107,6 @@ class SettingsController extends ApiMutableModelControllerBase
|
||||
}
|
||||
|
||||
if (count($result['validations']) <= 0) {
|
||||
|
||||
// save config if validated correctly
|
||||
$mdlProxyUserACL->serializeToConfig();
|
||||
Config::getInstance()->save();
|
||||
@@ -148,10 +150,8 @@ class SettingsController extends ApiMutableModelControllerBase
|
||||
{
|
||||
$result = array("result" => "failed");
|
||||
if ($this->request->isPost() && $this->request->hasPost("ACL")) {
|
||||
|
||||
$mdlProxyUserACL = $this->getModel();
|
||||
if ($uuid != null) {
|
||||
|
||||
$node = $mdlProxyUserACL->getNodeByReference('general.ACLs.ACL.' . $uuid);
|
||||
if ($node != null) {
|
||||
$result = array("result" => "failed", "validations" => array());
|
||||
@@ -254,7 +254,6 @@ class SettingsController extends ApiMutableModelControllerBase
|
||||
{
|
||||
$result = array("result" => "failed");
|
||||
if ($this->request->isPost() && $uuid != null && $this->request->hasPost("command")) {
|
||||
|
||||
$mdlProxyUserACL = $this->getModel();
|
||||
$count = $this->repackPriority();
|
||||
$nodes = $mdlProxyUserACL->general->ACLs->ACL->getNodes();
|
||||
@@ -315,8 +314,11 @@ class SettingsController extends ApiMutableModelControllerBase
|
||||
$ldapBindURL .= strpos($server['host'], "::") !== false ? "[{$server['host']}]" : $server['host'];
|
||||
$ldapBindURL .= !empty($server['ldap_port']) ? ":{$server['ldap_port']}" : "";
|
||||
$ldap_auth_server = $authFactory->get($server["name"]);
|
||||
if ($ldap_auth_server->connect($ldapBindURL, $server["ldap_binddn"],
|
||||
$server["ldap_bindpw"]) == false) {
|
||||
if ($ldap_auth_server->connect(
|
||||
$ldapBindURL,
|
||||
$server["ldap_binddn"],
|
||||
$server["ldap_bindpw"]
|
||||
) == false) {
|
||||
return gettext("Error connecting to LDAP server");
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
<menu>
|
||||
<Services>
|
||||
<WebProxy>
|
||||
<ProxyUserACL VisibleName="Group and User ACL" cssClass="fa fa-shield fa-fw" order="30" url="/ui/proxyuseracl/"/>
|
||||
<ProxyUserACL VisibleName="Groups and Users" order="30" url="/ui/proxyuseracl/"/>
|
||||
</WebProxy>
|
||||
</Services>
|
||||
</menu>
|
||||
|
||||
|
||||
@@ -39,5 +39,7 @@ $domain = strtoupper((string) Config::getInstance()->object()->system->domain);
|
||||
|
||||
array_map('unlink', glob("/usr/local/etc/squid/ACL_*.txt"));
|
||||
foreach ($mdlProxyUserACL->getNodeByReference('general.ACLs.ACL')->getNodes() as $acl) {
|
||||
file_put_contents("/usr/local/etc/squid/ACL_" . $acl["Priority"] . ".txt", $acl["Name"] . "\n" . ($acl["Group"]["user"]["selected"] == "1" ? $acl["Name"] . "@" . $domain . "\n" : ""));
|
||||
file_put_contents("/usr/local/etc/squid/ACL_" .
|
||||
$acl["Priority"] . ".txt", $acl["Name"] . "\n" .
|
||||
($acl["Group"]["user"]["selected"] == "1" ? $acl["Name"] . "@" . $domain . "\n" : ""));
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
ProxyUserACL.conf:/usr/local/etc/squid/auth/ProxyUserACL.conf
|
||||
ProxyUserACL.conf:/usr/local/etc/squid/auth/ProxyUserACL.conf
|
||||
|
||||
+11
-12
@@ -59,30 +59,30 @@ acl domains_{{ACL.Priority}} url_regex {{element|replace(".","\.")}}
|
||||
{% if ACL.Priority == priority|string %}
|
||||
{% if ACL.Group == "group" %}
|
||||
{% if ldap|length == 1 %}
|
||||
{% if helpers.exists('OPNsense.proxy.forward.icap.enable') and OPNsense.proxy.forward.icap.enable == '1' %}
|
||||
{% if helpers.exists('OPNsense.proxy.forward.icap.enable') and OPNsense.proxy.forward.icap.enable == '1' %}
|
||||
adaptation_access response_mod {{ACL.Black}} group_ldap_{{ACL.Priority}} domains_{{ACL.Priority}}
|
||||
adaptation_access request_mod {{ACL.Black}} group_ldap_{{ACL.Priority}} domains_{{ACL.Priority}}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if helpers.exists('OPNsense.ProxySSO.EnableSSO') and OPNsense.ProxySSO.EnableSSO == '1' %}
|
||||
http_access {{ACL.Black}} group_ldap_{{ACL.Priority}} domains_{{ACL.Priority}}
|
||||
{% else %}
|
||||
{% else %}
|
||||
{% for authcn in ldap[0].ldap_authcn.split(";") %}
|
||||
http_access {{ACL.Black}} group_ldap_{{ACL.Priority}}_{{ loop.index }} domains_{{ACL.Priority}}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if local|length == 1 %}
|
||||
{% if helpers.exists('OPNsense.proxy.forward.icap.enable') and OPNsense.proxy.forward.icap.enable == '1' %}
|
||||
{% if helpers.exists('OPNsense.proxy.forward.icap.enable') and OPNsense.proxy.forward.icap.enable == '1' %}
|
||||
adaptation_access response_mod {{ACL.Black}} group_local_{{ACL.Priority}} domains_{{ACL.Priority}}
|
||||
adaptation_access request_mod {{ACL.Black}} group_local_{{ACL.Priority}} domains_{{ACL.Priority}}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
http_access {{ACL.Black}} group_local_{{ACL.Priority}} domains_{{ACL.Priority}}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if helpers.exists('OPNsense.proxy.forward.icap.enable') and OPNsense.proxy.forward.icap.enable == '1' %}
|
||||
{% if helpers.exists('OPNsense.proxy.forward.icap.enable') and OPNsense.proxy.forward.icap.enable == '1' %}
|
||||
adaptation_access response_mod {{ACL.Black}} user_{{ACL.Priority}} domains_{{ACL.Priority}}
|
||||
adaptation_access request_mod {{ACL.Black}} user_{{ACL.Priority}} domains_{{ACL.Priority}}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
http_access {{ACL.Black}} user_{{ACL.Priority}} domains_{{ACL.Priority}}
|
||||
{% endif %}
|
||||
{% break %}
|
||||
@@ -90,4 +90,3 @@ http_access {{ACL.Black}} user_{{ACL.Priority}} domains_{{ACL.Priority}}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user