summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStephen Beaver <sbeaver@netgate.com>2016-02-03 11:01:47 -0500
committerStephen Beaver <sbeaver@netgate.com>2016-02-03 11:02:15 -0500
commit5d916fc76a1ffcd4d7b446ff063ecfd25f5dfad5 (patch)
treecfe761ee273bbff21741825ba06d9f53e4600633 /src
parentf519f112e034b35a3288be215110d93fa84e77f4 (diff)
downloadpfsense-5d916fc76a1ffcd4d7b446ff063ecfd25f5dfad5.zip
pfsense-5d916fc76a1ffcd4d7b446ff063ecfd25f5dfad5.tar.gz
Improvements to the priviledge filter functionality
Diffstat (limited to 'src')
-rw-r--r--src/etc/inc/priv.defs.inc20
-rw-r--r--src/etc/inc/priv.inc2
-rw-r--r--src/usr/local/www/diag_backup.php2
-rw-r--r--src/usr/local/www/index.php2
-rw-r--r--src/usr/local/www/system_usermanager_addprivs.php65
5 files changed, 70 insertions, 21 deletions
diff --git a/src/etc/inc/priv.defs.inc b/src/etc/inc/priv.defs.inc
index 06d0418..21bf0f4 100644
--- a/src/etc/inc/priv.defs.inc
+++ b/src/etc/inc/priv.defs.inc
@@ -43,11 +43,11 @@ $priv_list['page-diagnostics-authentication']['descr'] = gettext("Allow access t
$priv_list['page-diagnostics-authentication']['match'] = array();
$priv_list['page-diagnostics-authentication']['match'][] = "diag_authentication.php*";
-$priv_list['page-diagnostics-backup/restore'] = array();
-$priv_list['page-diagnostics-backup/restore']['name'] = gettext("WebCfg - Diagnostics: Backup/restore");
-$priv_list['page-diagnostics-backup/restore']['descr'] = gettext("Allow access to the 'Diagnostics: Backup/restore' page.");
-$priv_list['page-diagnostics-backup/restore']['match'] = array();
-$priv_list['page-diagnostics-backup/restore']['match'][] = "diag_backup.php*";
+$priv_list['page-diagnostics-backup-restore'] = array();
+$priv_list['page-diagnostics-backup-restore']['name'] = gettext("WebCfg - Diagnostics: Backup/restore");
+$priv_list['page-diagnostics-backup-restore']['descr'] = gettext("Allow access to the 'Diagnostics: Backup/restore' page.");
+$priv_list['page-diagnostics-backup-restore']['match'] = array();
+$priv_list['page-diagnostics-backup-restore']['match'][] = "diag_backup.php*";
$priv_list['page-diagnostics-configurationhistory'] = array();
$priv_list['page-diagnostics-configurationhistory']['name'] = gettext("WebCfg - Diagnostics: Configuration History");
@@ -430,11 +430,11 @@ $priv_list['page-xmlrpcinterfacestats']['descr'] = gettext("Allow access to the
$priv_list['page-xmlrpcinterfacestats']['match'] = array();
$priv_list['page-xmlrpcinterfacestats']['match'][] = "ifstats.php*";
-$priv_list['page-system-login/logout'] = array();
-$priv_list['page-system-login/logout']['name'] = gettext("WebCfg - System: Login / Logout / Dashboard");
-$priv_list['page-system-login/logout']['descr'] = gettext("Allow access to the 'System: Login / Logout' page and Dashboard.");
-$priv_list['page-system-login/logout']['match'] = array();
-$priv_list['page-system-login/logout']['match'][] = "index.php*";
+$priv_list['page-system-login-logout'] = array();
+$priv_list['page-system-login-logout']['name'] = gettext("WebCfg - System: Login / Logout / Dashboard");
+$priv_list['page-system-login-logout']['descr'] = gettext("Allow access to the 'System: Login / Logout' page and Dashboard.");
+$priv_list['page-system-login-logout']['match'] = array();
+$priv_list['page-system-login-logout']['match'][] = "index.php*";
$priv_list['page-interfaces'] = array();
$priv_list['page-interfaces']['name'] = gettext("WebCfg - Interfaces: WAN");
diff --git a/src/etc/inc/priv.inc b/src/etc/inc/priv.inc
index b834daa..6315f72 100644
--- a/src/etc/inc/priv.inc
+++ b/src/etc/inc/priv.inc
@@ -338,7 +338,7 @@ function getAllowedPages($username, &$attributes = array()) {
function sort_user_privs($privs) {
// Privileges to place first, to redirect properly.
- $priority_privs = array("page-dashboard-all", "page-system-login/logout");
+ $priority_privs = array("page-dashboard-all", "page-system-login-logout");
$fprivs = array_intersect($privs, $priority_privs);
$sprivs = array_diff($privs, $priority_privs);
diff --git a/src/usr/local/www/diag_backup.php b/src/usr/local/www/diag_backup.php
index 30da41b..242551c 100644
--- a/src/usr/local/www/diag_backup.php
+++ b/src/usr/local/www/diag_backup.php
@@ -57,7 +57,7 @@
*/
##|+PRIV
-##|*IDENT=page-diagnostics-backup/restore
+##|*IDENT=page-diagnostics-backup-restore
##|*NAME=Diagnostics: Backup/restore
##|*DESCR=Allow access to the 'Diagnostics: Backup/restore' page.
##|*MATCH=diag_backup.php*
diff --git a/src/usr/local/www/index.php b/src/usr/local/www/index.php
index 25a6a57..55de55e 100644
--- a/src/usr/local/www/index.php
+++ b/src/usr/local/www/index.php
@@ -57,7 +57,7 @@
*/
##|+PRIV
-##|*IDENT=page-system-login/logout
+##|*IDENT=page-system-login-logout
##|*NAME=System: Login / Logout / Dashboard
##|*DESCR=Allow access to the 'System: Login / Logout' page and Dashboard.
##|*MATCH=index.php*
diff --git a/src/usr/local/www/system_usermanager_addprivs.php b/src/usr/local/www/system_usermanager_addprivs.php
index 62c6636..35753c8 100644
--- a/src/usr/local/www/system_usermanager_addprivs.php
+++ b/src/usr/local/www/system_usermanager_addprivs.php
@@ -93,6 +93,7 @@ $spriv_list = $priv_list;
uasort($spriv_list, admusercmp);
if ($_POST) {
+
conf_mount_rw();
unset($input_errors);
@@ -186,8 +187,15 @@ $section->addInput(new Form_Select(
true
))->addClass('multiselect')
->setHelp('Hold down CTRL (PC)/COMMAND (Mac) key to select multiple items');
- // ->setAttribute('style', 'height:400px;');
+$section->addInput(new Form_Select(
+ 'shadow',
+ 'Shadow',
+ null,
+ build_priv_list(),
+ true
+))->addClass('shadowselect')
+ ->setHelp('Hold down CTRL (PC)/COMMAND (Mac) key to select multiple items');
$section->addInput(new Form_Input(
'filtertxt',
@@ -240,6 +248,7 @@ events.push(function() {
<?php
+
// Build a list of privilege descriptions
if (is_array($spriv_list)) {
$id = 0;
@@ -257,24 +266,39 @@ events.push(function() {
echo $jdescs;
}
?>
+
+ $('.shadowselect').hide();
+
// Set the number of options to display
$('.multiselect').attr("size","20");
+ $('.shadowselect').attr("size","20");
// When the 'sysprivs" selector is clicked, we display a description
$('.multiselect').click(function() {
$('#pdesc').html('<span class="text-info">' + descs[$(this).children('option:selected').index()] + '</span>');
+
+ // and update the shadow list from the real list
+ $(".multiselect option").each(function() {
+ shadowoption = $('.shadowselect option').filter('[value=' + $(this).val() + ']');
+
+ if ($(this).is(':selected')) {
+ shadowoption.prop("selected", true);
+ } else {
+ shadowoption.prop("selected", false);
+ }
+ });
});
$('#btnfilter').prop('type', 'button');
$('#btnfilter').click(function() {
searchterm = $('#filtertxt').val().toLowerCase();
+ copyselect(true);
+ // Then filter
$(".multiselect > option").each(function() {
- if (this.text.toLowerCase().indexOf(searchterm) > -1 ) {
- $(this).show();
- } else {
- $(this).hide();
+ if (this.text.toLowerCase().indexOf(searchterm) == -1 ) {
+ $(this).remove();
}
});
});
@@ -282,9 +306,10 @@ events.push(function() {
$('#btnclear').prop('type', 'button');
$('#btnclear').click(function() {
- $(".multiselect > option").each(function() {
- $(this).show();
- });
+ // Copy all options from shadow to sysprivs
+ copyselect(true)
+
+ $('#filtertxt').val('');
});
$('#filtertxt').keypress(function(e) {
@@ -296,9 +321,33 @@ events.push(function() {
// On submit unhide all options (or else they will not submit)
$('form').submit(function() {
+
$(".multiselect > option").each(function() {
$(this).show();
});
+
+ $('.shadowselect').remove();
+ });
+
+ function copyselect(selected) {
+ // Copy all optionsfrom shadow to sysprivs
+ $('.multiselect').html($('.shadowselect').html());
+
+ if (selected) {
+ // Update the shadow list from the real list
+ $(".shadowselect option").each(function() {
+ multioption = $('.multiselect option').filter('[value=' + $(this).val() + ']');
+ if ($(this).is(':selected')) {
+ multioption.prop("selected", true);
+ } else {
+ multioption.prop("selected", false);
+ }
+ });
+ }
+ }
+
+ $('.multiselect').mouseup(function () {
+ $('.multiselect').trigger('click');
});
});
//]]>
OpenPOWER on IntegriCloud