mirror of
https://github.com/opnsense/plugins.git
synced 2026-06-09 08:56:23 -04:00
www/web-proxy-useracl: only encode in template
This commit is contained in:
parent
05a48a36ca
commit
798b7af834
3 changed files with 5 additions and 23 deletions
|
|
@ -1,5 +1,6 @@
|
|||
PLUGIN_NAME= web-proxy-useracl
|
||||
PLUGIN_VERSION= 1.1
|
||||
PLUGIN_REVISION= 1
|
||||
PLUGIN_COMMENT= Group and user ACL for the web proxy
|
||||
PLUGIN_MAINTAINER= kekek2@ya.ru
|
||||
PLUGIN_WWW= https://smart-soft.ru
|
||||
|
|
|
|||
|
|
@ -54,15 +54,11 @@ 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);
|
||||
}
|
||||
$grid = new UIModelGrid($mdlProxyUserACL->general->ACLs->ACL);
|
||||
return $grid->fetchBindRequest(
|
||||
$this->request,
|
||||
array("Group", "Name", "Domains", "Black", "Priority", "uuid"),
|
||||
"Priority"
|
||||
array('Group', 'Name', 'Domains', 'Black', 'Priority', 'uuid'),
|
||||
'Priority'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +89,6 @@ class SettingsController extends ApiMutableModelControllerBase
|
|||
$mdlProxyUserACL->general->ACLs->ACL->{$key}->Priority = (string)($priority + 1);
|
||||
}
|
||||
$node = $mdlProxyUserACL->general->ACLs->ACL->Add();
|
||||
$post["Domains"] = \OPNsense\Proxy\Api\SettingsController::encode($post["Domains"]);
|
||||
$node->setNodes($post);
|
||||
$find = $this->checkName($post["Name"], $post["Group"]);
|
||||
if ($find !== true) {
|
||||
|
|
@ -133,8 +128,6 @@ class SettingsController extends ApiMutableModelControllerBase
|
|||
|
||||
$node = $mdlProxyUserACL->getNodeByReference('general.ACLs.ACL.' . $uuid);
|
||||
if ($node != null) {
|
||||
// return node
|
||||
$node->Domains = $this->decode((string)$node->Domains);
|
||||
return array("ACL" => $node->getNodes());
|
||||
}
|
||||
|
||||
|
|
@ -157,7 +150,6 @@ class SettingsController extends ApiMutableModelControllerBase
|
|||
$result = array("result" => "failed", "validations" => array());
|
||||
$ACLInfo = $this->request->getPost("ACL");
|
||||
$ACLInfo["Hex"] = $this->strToHex($ACLInfo["Name"]);
|
||||
$ACLInfo["Domains"] = \OPNsense\Proxy\Api\SettingsController::encode($ACLInfo["Domains"]);
|
||||
$old_priority = (string)$node->Priority;
|
||||
$new_priority = $ACLInfo["Priority"];
|
||||
|
||||
|
|
@ -366,15 +358,4 @@ class SettingsController extends ApiMutableModelControllerBase
|
|||
}
|
||||
return $hex;
|
||||
}
|
||||
|
||||
private function decode($domains)
|
||||
{
|
||||
$result = array();
|
||||
foreach (explode(",", $domains) as $domain) {
|
||||
if ($domain != "") {
|
||||
$result[] = idn_to_utf8($domain);
|
||||
}
|
||||
}
|
||||
return implode(",", $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@ acl user_{{ACL.Priority}} proxy_auth "/usr/local/etc/squid/ACL_useracl_{{ ACL.Pr
|
|||
{% if ldap|length == 1 or local|length == 1 %}
|
||||
{% for element in ACL.Domains.split(",") %}
|
||||
{% if '^' in element or '\\' in element or '$' in element or '[' in element %}
|
||||
acl domains_{{ACL.Priority}} url_regex {{element}}
|
||||
acl domains_{{ACL.Priority}} url_regex {{element|encode_idna}}
|
||||
{% else %}
|
||||
acl domains_{{ACL.Priority}} url_regex {{element|replace(".","\.")}}
|
||||
acl domains_{{ACL.Priority}} url_regex {{element|encode_idna|replace(".","\.")}}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
|
|
|||
Loading…
Reference in a new issue