summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStephen Beaver <sbeaver@netgate.com>2016-03-16 13:53:05 -0400
committerStephen Beaver <sbeaver@netgate.com>2016-03-16 13:53:23 -0400
commit098604d38b865490789ffada155eac9572ff4e20 (patch)
treed080ba8a2959c5242f5a9981a0586fdb9098cacc /src
parenta11064ea40aaafa34a0f7dc17c748143c9579c31 (diff)
downloadpfsense-098604d38b865490789ffada155eac9572ff4e20.zip
pfsense-098604d38b865490789ffada155eac9572ff4e20.tar.gz
Converted LDAP container picker to modal
Diffstat (limited to 'src')
-rw-r--r--src/etc/pfSense.obsoletedfiles1
-rw-r--r--src/usr/local/www/system_authservers.php162
-rw-r--r--src/usr/local/www/system_usermanager_settings.php2
-rw-r--r--src/usr/local/www/system_usermanager_settings_ldapacpicker.php154
4 files changed, 143 insertions, 176 deletions
diff --git a/src/etc/pfSense.obsoletedfiles b/src/etc/pfSense.obsoletedfiles
index 9903a4b..3aa1b85 100644
--- a/src/etc/pfSense.obsoletedfiles
+++ b/src/etc/pfSense.obsoletedfiles
@@ -861,6 +861,7 @@
/usr/local/www/status_slbd_vs.php
/usr/local/www/system_advanced.php
/usr/local/www/system_advanced_create_certs.php
+/usr/local/www/system_usermanager_settings_ldapacpicker.php
/usr/local/www/system_firmware.php
/usr/local/www/system_firmware_auto.php
/usr/local/www/system_firmware_check.php
diff --git a/src/usr/local/www/system_authservers.php b/src/usr/local/www/system_authservers.php
index 7665455..59b2fb1 100644
--- a/src/usr/local/www/system_authservers.php
+++ b/src/usr/local/www/system_authservers.php
@@ -64,9 +64,74 @@
require("guiconfig.inc");
require_once("auth.inc");
+// Have we been called to populate the "Select a container" modal?
+if ($_REQUEST['ajax']) {
+
+ $ous = array();
+ $authcfg = array();
+
+ $authcfg['ldap_port'] = $_REQUEST['port'];
+ $authcfg['ldap_basedn'] = $_REQUEST['basedn'];
+ $authcfg['host'] = $_REQUEST['host'];
+ $authcfg['ldap_scope'] = $_REQUEST['scope'];
+ $authcfg['ldap_binddn'] = $_REQUEST['binddn'];
+ $authcfg['ldap_bindpw'] = $_REQUEST['bindpw'];
+ $authcfg['ldap_urltype'] = $_REQUEST['urltype'];
+ $authcfg['ldap_protver'] = $_REQUEST['proto'];
+ $authcfg['ldap_authcn'] = explode(";", $_REQUEST['authcn']);
+ $authcfg['ldap_caref'] = $_REQUEST['cert'];
+
+ $ous = ldap_get_user_ous(true, $authcfg);
+
+ if (empty($ous)) {
+ print('<span class="text-danger">Could not connect to the LDAP server. Please check your LDAP configuration.</span>');
+ } else {
+ $section = new Form_Section("Select containers for authentication");
+ $group = new Form_MultiCheckboxGroup('Containers');
+
+ if (is_array($ous)) {
+ $idx = 0;
+
+ foreach ($ous as $ou) {
+ $group->add(new Form_MultiCheckbox(
+ 'ou' . $idx,
+ '',
+ $ou,
+ in_array($ou, $authcfg['ldap_authcn']),
+ $ou
+ ));
+
+ $idx++;
+ }
+ }
+
+ $section->add($group);
+
+ // Create a "Save button"
+ $btnsvcont = new Form_Button(
+ 'svcontbtn',
+ 'Save',
+ null,
+ 'fa-save'
+ );
+
+ $btnsvcont->addClass("btn-primary");
+
+ $section->addInput(new Form_StaticText(
+ '',
+ $btnsvcont
+ ));
+
+ print($section);
+ }
+
+ exit;
+}
+
if (is_numericint($_GET['id'])) {
$id = $_GET['id'];
}
+
if (isset($_POST['id']) && is_numericint($_POST['id'])) {
$id = $_POST['id'];
}
@@ -754,11 +819,24 @@ if (isset($id) && $a_server[$id])
}
$form->add($section);
+
+// Create a largely empty modal to show the available containers. We will populate it via AJAX later
+$modal = new Modal("LDAP containers", "containers", true);
+
+$modal->addInput(new Form_StaticText(
+ 'Test results',
+ '<span id="serverlist">Testing pfSense LDAP settings... One moment please...' . $g['product_name'] . '</span>'
+));
+
+$form->add($modal);
+
print $form;
?>
<script type="text/javascript">
//<![CDATA[
-events.push(function(){
+events.push(function() {
+
+ // Create an AJAX request (to this page) to get the container list and controls
function select_clicked() {
if (document.getElementById("ldap_port").value == '' ||
document.getElementById("ldap_host").value == '' ||
@@ -776,26 +854,68 @@ events.push(function(){
return;
}
}
- var url = 'system_usermanager_settings_ldapacpicker.php?';
- url += 'port=' + document.getElementById("ldap_port").value;
- url += '&host=' + document.getElementById("ldap_host").value;
- url += '&scope=' + document.getElementById("ldap_scope").value;
- url += '&basedn=' + document.getElementById("ldap_basedn").value;
- url += '&binddn=' + document.getElementById("ldap_binddn").value;
- url += '&bindpw=' + document.getElementById("ldap_bindpw").value;
- url += '&urltype=' + document.getElementById("ldap_urltype").value;
- url += '&proto=' + document.getElementById("ldap_protver").value;
- url += '&authcn=' + document.getElementById("ldapauthcontainers").value;
- <?php if (count($a_ca) > 0): ?>
- url += '&cert=' + document.getElementById("ldap_caref").value;
- <?php else: ?>
- url += '&cert=';
- <?php endif; ?>
-
- var oWin = window.open(url, "pfSensePop", "width=620,height=400,top=150,left=150");
- if (oWin == null || typeof(oWin) == "undefined") {
- alert("<?=gettext('Popup blocker detected. Action aborted.');?>");
- }
+
+ var ajaxRequest;
+ var authserver = $('#authmode').val();
+ var cert;
+
+<?php if (count($a_ca) > 0): ?>
+ cert = $('#ldap_caref').val();
+<?php else: ?>
+ cert = '';
+<?php endif; ?>
+
+ $('#containers').modal('show');
+
+ ajaxRequest = $.ajax(
+ {
+ url: "/system_authservers.php",
+ type: "post",
+ data: {
+ ajax: "ajax",
+ port: $('#ldap_port').val(),
+ host: $('#ldap_host').val(),
+ scope: $('#ldap_scope').val(),
+ basedn: $('#ldap_basedn').val(),
+ binddn: $('#ldap_binddn').val(),
+ bindpw: $('#ldap_bindpw').val(),
+ urltype:$('#ldap_urltype').val(),
+ proto: $('#ldap_protver').val(),
+ authcn: $('#ldapauthcontainers').val(),
+ cert: cert
+ }
+ }
+ );
+
+ // Deal with the results of the above ajax call
+ ajaxRequest.done(function (response, textStatus, jqXHR) {
+ $('#serverlist').html(response);
+
+ // The button handler needs to be here because until the modal has been populated
+ // the controls we need to attach handlers to do not exist
+ $('#svcontbtn').prop("type", "button");
+ $('#svcontbtn').removeAttr("href");
+
+ $('#svcontbtn').click(function () {
+ var ous = $('[id^=ou]').length;
+ var i;
+
+ $('#ldapauthcontainers').val("");
+
+ for (i = 0; i < ous; i++) {
+ if ($('#ou' + i).prop("checked")) {
+ if ($('#ldapauthcontainers').val() != "") {
+ $('#ldapauthcontainers').val($('#ldapauthcontainers').val() +";");
+ }
+
+ $('#ldapauthcontainers').val($('#ldapauthcontainers').val() + $('#ou' + i).val());
+ }
+ }
+
+ $('#containers').modal('hide');
+ });
+ });
+
}
function set_ldap_port() {
diff --git a/src/usr/local/www/system_usermanager_settings.php b/src/usr/local/www/system_usermanager_settings.php
index f011132..3bdca81 100644
--- a/src/usr/local/www/system_usermanager_settings.php
+++ b/src/usr/local/www/system_usermanager_settings.php
@@ -253,7 +253,7 @@ $form->add($modal);
print $form;
-// If the user clicked "Save & Test" shw the modal and populate it with the test results via AJAX
+// If the user clicked "Save & Test" show the modal and populate it with the test results via AJAX
if ($save_and_test) {
?>
<script type="text/javascript">
diff --git a/src/usr/local/www/system_usermanager_settings_ldapacpicker.php b/src/usr/local/www/system_usermanager_settings_ldapacpicker.php
deleted file mode 100644
index 60535c3..0000000
--- a/src/usr/local/www/system_usermanager_settings_ldapacpicker.php
+++ /dev/null
@@ -1,154 +0,0 @@
-<?php
-/*
- system_usermanager_settings_ldapacpicker.php
-*/
-/* ====================================================================
- * Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgment:
- * "This product includes software developed by the pfSense Project
- * for use in the pfSense software distribution. (http://www.pfsense.org/).
- *
- * 4. The names "pfSense" and "pfSense Project" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * coreteam@pfsense.org.
- *
- * 5. Products derived from this software may not be called "pfSense"
- * nor may "pfSense" appear in their names without prior written
- * permission of the Electric Sheep Fencing, LLC.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- *
- * "This product includes software developed by the pfSense Project
- * for use in the pfSense software distribution (http://www.pfsense.org/).
- *
- * THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ====================================================================
- *
- */
-
-##|+PRIV
-##|*IDENT=page-system-usermanager-settings-ldappicker
-##|*NAME=System: User Manager: Settings: LDAP Picker
-##|*DESCR=Allow access to the 'System: User Manager: Settings: LDAP Picker' page.
-##|*MATCH=system_usermanager_settings_ldapacpicker.php*
-##|-PRIV
-
-require("guiconfig.inc");
-require_once("auth.inc");
-
-$ous = array();
-
-if ($_GET) {
- $authcfg = array();
- $authcfg['ldap_port'] = $_GET['port'];
- $authcfg['ldap_basedn'] = $_GET['basedn'];
- $authcfg['host'] = $_GET['host'];
- $authcfg['ldap_scope'] = $_GET['scope'];
- $authcfg['ldap_binddn'] = $_GET['binddn'];
- $authcfg['ldap_bindpw'] = $_GET['bindpw'];
- $authcfg['ldap_urltype'] = $_GET['urltype'];
- $authcfg['ldap_protver'] = $_GET['proto'];
- $authcfg['ldap_authcn'] = explode(";", $_GET['authcn']);
- $authcfg['ldap_caref'] = $_GET['cert'];
- $ous = ldap_get_user_ous(true, $authcfg);
-}
-
-?>
-<html>
- <head>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="stylesheet" href="/bootstrap/css/pfSense.css" />
- <link rel="stylesheet" href="/font-awesome/css/font-awesome.min.css">
- </head>
-<script type="text/javascript">
-//<![CDATA[
-function post_choices() {
-
- var ous = <?=count($ous);?>;
- var i;
- opener.document.forms[0].ldapauthcontainers.value="";
- for (i = 0; i < ous; i++) {
- if (document.forms[0].ou[i].checked) {
- if (opener.document.forms[0].ldapauthcontainers.value != "") {
- opener.document.forms[0].ldapauthcontainers.value+=";";
- }
- opener.document.forms[0].ldapauthcontainers.value+=document.forms[0].ou[i].value;
- }
- }
- window.close();
--->
-}
-//]]>
-</script>
-
- <body>
- <div class="panel panel-default">
- <div class="panel-heading"><h2 class="panel-title"><?=gettext('LDAP Containers')?></h2></div>
- <div class="panel-body">
- <form method="post" action="system_usermanager_settings_ldapacpicker.php">
-<?php if (empty($ous)): ?>
- <p><?=gettext("Could not connect to the LDAP server. Please check your LDAP configuration.");?></p>
- <button type='button' class="btn btn-sm btn-warning" value='<?=gettext("Close"); ?>' onClick="window.close();">
- <i class="fa fa-undo icon-embed-btn"></i>
- <?=gettext("Close"); ?>
- </button>
-<?php else: ?>
- <b><?=gettext("Select containers for authentication:");?></b>
- <br/>
- <div class="table">
- <table class="table table-hover table-striped">
- <tbody>
-<?php
- if (is_array($ous)) {
- foreach ($ous as $ou) {
- if (in_array($ou, $authcfg['ldap_authcn'])) {
- $CHECKED=" checked";
- } else {
- $CHECKED="";
- }
- echo " <tr><td><input type='checkbox' value='{$ou}' id='ou' name='ou[]'{$CHECKED}> {$ou}<br /></td></tr>\n";
- }
- }
-?>
- </tbody>
- </table>
- </div>
- <p/>
-
- <button type='button' class="btn btn-sm btn-primary" value='<?=gettext("Save");?>' onClick="post_choices();">
- <i class="fa fa-save icon-embed-btn"></i>
- <?=gettext("Save");?>
- </button>
-<?php endif; ?>
- </form>
- </div>
- </body>
- <script src="/bootstrap/js/bootstrap.min.js"></script>
-</html>
OpenPOWER on IntegriCloud