system_authservers.php 31.6 KB
Newer Older
Ad Schellevis's avatar
Ad Schellevis committed
1
<?php
2

Ad Schellevis's avatar
Ad Schellevis committed
3
/*
4
    Copyright (C) 2014-2015 Deciso B.V.
Ad Schellevis's avatar
Ad Schellevis committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
    Copyright (C) 2010 Ermal Luçi
    Copyright (C) 2008 Shrew Soft Inc.
    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.

    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS 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
    AUTHOR 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.
*/
30
require_once("guiconfig.inc");
Ad Schellevis's avatar
Ad Schellevis committed
31 32
require_once("auth.inc");

33 34

$auth_server_types = array(
35
    'ldap' => "LDAP",
36 37
    'radius' => "Radius",
    'voucher' => "Voucher"
38
);
39

Ad Schellevis's avatar
Ad Schellevis committed
40

41
if (!isset($config['system']['authserver'])) {
42 43
    $config['system']['authserver'] = array();
}
Ad Schellevis's avatar
Ad Schellevis committed
44

45 46 47 48
if (empty($config['ca']) || !is_array($config['ca'])) {
    $config['ca'] = array();
}

Ad Schellevis's avatar
Ad Schellevis committed
49
$a_servers = auth_get_authserver_list();
50
$a_server = array();
51 52 53
foreach ($a_servers as $servers) {
    $a_server[] = $servers;
}
Ad Schellevis's avatar
Ad Schellevis committed
54

55 56 57 58 59
$act = null;
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    // input record id, if valid
    if (isset($_GET['id']) && isset($a_server[$_GET['id']])) {
        $id = $_GET['id'];
60
    }
61 62
    if (isset($_GET['act'])) {
        $act = $_GET['act'];
63
    }
64 65 66 67 68 69 70 71
    $pconfig = array();
    if ($act == "new") {
        $pconfig['ldap_protver'] = 3;
        $pconfig['radius_srvcs'] = "both";
        $pconfig['radius_auth_port'] = "1812";
        $pconfig['radius_acct_port'] = "1813";
        $pconfig['type'] = 'ldap';
    } elseif ($act == "edit" && isset($id)) {
72 73 74 75 76 77 78 79 80 81 82 83 84 85
        $pconfig['type'] = $a_server[$id]['type'];
        $pconfig['name'] = $a_server[$id]['name'];

        if ($pconfig['type'] == "ldap") {
            $pconfig['ldap_caref'] = $a_server[$id]['ldap_caref'];
            $pconfig['ldap_host'] = $a_server[$id]['host'];
            $pconfig['ldap_port'] = $a_server[$id]['ldap_port'];
            $pconfig['ldap_urltype'] = $a_server[$id]['ldap_urltype'];
            $pconfig['ldap_protver'] = $a_server[$id]['ldap_protver'];
            $pconfig['ldap_scope'] = $a_server[$id]['ldap_scope'];
            $pconfig['ldap_basedn'] = $a_server[$id]['ldap_basedn'];
            $pconfig['ldap_authcn'] = $a_server[$id]['ldap_authcn'];
            $pconfig['ldap_extended_query'] = $a_server[$id]['ldap_extended_query'];
            $pconfig['ldap_attr_user'] = $a_server[$id]['ldap_attr_user'];
86 87
            if (!empty($a_server[$id]['ldap_binddn'])) {
                $pconfig['ldap_binddn'] = $a_server[$id]['ldap_binddn'];
88
            }
89 90 91 92
            if (!empty($a_server[$id]['ldap_bindpw'])) {
                $pconfig['ldap_bindpw'] = $a_server[$id]['ldap_bindpw'];
            }
        } elseif ($pconfig['type'] == "radius") {
93 94 95 96 97 98
            $pconfig['radius_host'] = $a_server[$id]['host'];
            $pconfig['radius_auth_port'] = $a_server[$id]['radius_auth_port'];
            $pconfig['radius_acct_port'] = $a_server[$id]['radius_acct_port'];
            $pconfig['radius_secret'] = $a_server[$id]['radius_secret'];
            $pconfig['radius_timeout'] = $a_server[$id]['radius_timeout'];

99 100
            if (!empty($pconfig['radius_auth_port']) &&
                !empty($pconfig['radius_acct_port'])) {
101
                $pconfig['radius_srvcs'] = "both";
102
            } else {
103 104 105
                $pconfig['radius_srvcs'] = "auth";
            }

106
            if (empty($pconfig['radius_auth_port'])) {
107 108 109 110
                $pconfig['radius_auth_port'] = 1812;
            }
        }
    }
Ad Schellevis's avatar
Ad Schellevis committed
111

112
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
113
    $input_errors = array();
114
    $pconfig = $_POST;
115 116
    if (isset($pconfig['id']) && isset($a_server[$pconfig['id']])) {
        $id = $pconfig['id'];
117
    }
118 119
    if (isset($pconfig['act'])) {
        $act = $pconfig['act'];
120
    }
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
    if (isset($pconfig['save'])) {
      /* input validation */
      if ($pconfig['type'] == "ldap") {
          $reqdfields = explode(" ", "name type ldap_host ldap_port ".
                          "ldap_urltype ldap_protver ldap_scope ".
                          "ldap_attr_user ldapauthcontainers");
          $reqdfieldsn = array(
              gettext("Descriptive name"),
              gettext("Type"),
              gettext("Hostname or IP"),
              gettext("Port value"),
              gettext("Transport"),
              gettext("Protocol version"),
              gettext("Search level"),
              gettext("User naming Attribute"),
              gettext("Authentication container"));

          if (!empty($pconfig['ldap_binddn']) && !empty($pconfig['ldap_bindpw'])) {
              $reqdfields[] = "ldap_binddn";
              $reqdfields[] = "ldap_bindpw";
              $reqdfieldsn[] = gettext("Bind user DN");
              $reqdfieldsn[] = gettext("Bind Password");
          }
      }

      if ($pconfig['type'] == "radius") {
          $reqdfields = explode(" ", "name type radius_host radius_srvcs");
          $reqdfieldsn = array(
              gettext("Descriptive name"),
              gettext("Type"),
              gettext("Hostname or IP"),
              gettext("Services"));

          if ($pconfig['radisu_srvcs'] == "both" ||
              $pconfig['radisu_srvcs'] == "auth") {
              $reqdfields[] = "radius_auth_port";
              $reqdfieldsn[] = gettext("Authentication port value");
          }

          if ($id == null) {
              $reqdfields[] = "radius_secret";
              $reqdfieldsn[] = gettext("Shared Secret");
          }
      }

166
      do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
167

168
      if (!empty($pconfig['ldap_host']) && preg_match("/[^a-zA-Z0-9\.\-_]/", $pconfig['ldap_host'])) {
169 170
          $input_errors[] = gettext("The host name contains invalid characters.");
      }
171
      if (!empty($pconfig['radius_host']) && preg_match("/[^a-zA-Z0-9\.\-_]/", $pconfig['radius_host'])) {
172 173 174 175 176 177 178
          $input_errors[] = gettext("The host name contains invalid characters.");
      }

      if (auth_get_authserver($pconfig['name']) && !isset($id)) {
          $input_errors[] = gettext("An authentication server with the same name already exists.");
      }

179
      if (($pconfig['type'] == "radius") && isset($pconfig['radius_timeout']) && !empty($pconfig['radius_timeout']) && (!is_numeric($pconfig['radius_timeout']) || (is_numeric($pconfig['radius_timeout']) && ($pconfig['radius_timeout'] <= 0)))) {
180 181
          $input_errors[] = gettext("RADIUS Timeout value must be numeric and positive.");
      }
182 183 184 185
      if (empty($pconfig['name'])) {
          $input_errors[] = gettext("A server name must be provided");
      }

186 187 188 189 190
      if (count($input_errors) == 0) {
          $server = array();
          $server['refid'] = uniqid();
          if (isset($id)) {
              $server = $a_server[$id];
191 192 193
          } else {
              $server['type'] = $pconfig['type'];
              $server['name'] = $pconfig['name'];
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
          }

          if ($server['type'] == "ldap") {
              if (!empty($pconfig['ldap_caref'])) {
                  $server['ldap_caref'] = $pconfig['ldap_caref'];
              }
              $server['host'] = $pconfig['ldap_host'];
              $server['ldap_port'] = $pconfig['ldap_port'];
              $server['ldap_urltype'] = $pconfig['ldap_urltype'];
              $server['ldap_protver'] = $pconfig['ldap_protver'];
              $server['ldap_scope'] = $pconfig['ldap_scope'];
              $server['ldap_basedn'] = $pconfig['ldap_basedn'];
              $server['ldap_authcn'] = $pconfig['ldapauthcontainers'];
              $server['ldap_extended_query'] = $pconfig['ldap_extended_query'];
              $server['ldap_attr_user'] = $pconfig['ldap_attr_user'];
              if (!empty($pconfig['ldap_binddn']) && !empty($pconfig['ldap_bindpw']) ){
                  $server['ldap_binddn'] = $pconfig['ldap_binddn'];
                  $server['ldap_bindpw'] = $pconfig['ldap_bindpw'];
              } else {
                  if (isset($server['ldap_binddn'])) {
                      unset($server['ldap_binddn']);
                  }
                  if (isset($server['ldap_bindpw'])) {
                      unset($server['ldap_bindpw']);
                  }
              }
          } elseif ($server['type'] == "radius") {
              $server['host'] = $pconfig['radius_host'];

              if (!empty($pconfig['radius_secret'])) {
                  $server['radius_secret'] = $pconfig['radius_secret'];
              }

              if (!empty($pconfig['radius_timeout'])) {
                  $server['radius_timeout'] = $pconfig['radius_timeout'];
              } else {
                  $server['radius_timeout'] = 5;
              }

              if ($pconfig['radius_srvcs'] == "both") {
                  $server['radius_auth_port'] = $pconfig['radius_auth_port'];
                  $server['radius_acct_port'] = $pconfig['radius_acct_port'];
              }

              if ($pconfig['radius_srvcs'] == "auth") {
                  $server['radius_auth_port'] = $pconfig['radius_auth_port'];
                  unset($server['radius_acct_port']);
              }
          }

          if (isset($id) && isset($config['system']['authserver'][$id])) {
              $config['system']['authserver'][$id] = $server;
          } else {
              $config['system']['authserver'][] = $server;
          }

          write_config();
251
          header("Location: system_authservers.php");
252 253 254 255 256 257 258 259 260 261
      } else {
          $act = "edit";
      }
    } elseif (isset($pconfig['act']) && $pconfig['act'] == 'del' && isset($id)) {
        /* Remove server from main list. */
        $serverdeleted = $a_server[$id]['name'];
        foreach ($config['system']['authserver'] as $k => $as) {
            if ($config['system']['authserver'][$k]['name'] == $serverdeleted) {
                unset($config['system']['authserver'][$k]);
            }
262
        }
263 264 265
        $savemsg = gettext("Authentication Server")." {$serverdeleted} ".
                    gettext("deleted")."<br />";
        write_config($savemsg);
266
        header("Location: system_authservers.php");
267 268
    }

269
}
270

271 272 273 274 275
// list of all possible fields for auth item (used for form init)
$all_authfields = array('type','name','ldap_caref','ldap_host','ldap_port','ldap_urltype','ldap_protver','ldap_scope',
        'ldap_basedn','ldap_authcn','ldap_extended_query','ldap_binddn','ldap_bindpw','ldap_attr_user','radius_host',
        'radius_auth_port','radius_acct_port','radius_secret','radius_timeout','radius_srvcs'
    );
276 277


278 279 280
foreach ($all_authfields as $fieldname) {
    if (!isset($pconfig[$fieldname])) {
        $pconfig[$fieldname] = null;
281
    }
Ad Schellevis's avatar
Ad Schellevis committed
282
}
283 284
legacy_html_escape_form_data($pconfig);
legacy_html_escape_form_data($a_server);
Ad Schellevis's avatar
Ad Schellevis committed
285 286

include("head.inc");
Ad Schellevis's avatar
Ad Schellevis committed
287

288 289 290 291 292
$main_buttons = array();
if (!isset($_GET['act']) || $_GET['act'] != 'new')
{
    $main_buttons[] = array('label'=>gettext('Add server'), 'href'=>'system_authservers.php?act=new');
}
Ad Schellevis's avatar
Ad Schellevis committed
293

Ad Schellevis's avatar
Ad Schellevis committed
294 295
?>

Ad Schellevis's avatar
Ad Schellevis committed
296

297
<body>
Ad Schellevis's avatar
Ad Schellevis committed
298

Ad Schellevis's avatar
Ad Schellevis committed
299 300 301
<script type="text/javascript">
//<![CDATA[
function select_clicked() {
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
    if (document.getElementById("ldap_port").value == '' ||
        document.getElementById("ldap_host").value == '' ||
        document.getElementById("ldap_scope").value == '' ||
        document.getElementById("ldap_basedn").value == '' ) {
          alert("<?=gettext("Please fill the required values.");?>");
          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($config['ca']) > 0) :
320
?>
321 322 323 324 325
          url += '&cert=' + document.getElementById("ldap_caref").value;
          <?php
else :?>
          url += '&cert=';
          <?php
326
endif; ?>
327
        var oWin = window.open(url,"OPNsense","width=620,height=400,top=150,left=150, scrollbars=yes");
Ad Schellevis's avatar
Ad Schellevis committed
328
        if (oWin==null || typeof(oWin)=="undefined")
Fabian Franz's avatar
Fabian Franz committed
329
			alert("<?=gettext('Popup blocker detected. Action aborted.');?>");
Ad Schellevis's avatar
Ad Schellevis committed
330 331
}

332 333
$( document ).ready(function() {
    $("#type").change(function(){
334 335 336
        $(".auth_radius").addClass('hidden');
        $(".auth_ldap").addClass('hidden');
        $(".auth_voucher").addClass('hidden');
337 338 339 340 341 342
        if ($("#type").val() == 'ldap') {
            $(".auth_ldap").removeClass('hidden');
        } else if ($("#type").val() == 'radius') {
            $(".auth_radius").removeClass('hidden');
        }
    });
Ad Schellevis's avatar
Ad Schellevis committed
343

344 345 346
    $("#ldap_urltype").change(function(){
        $("#ldap_port").val($(this).find(':selected').data('port'));
    });
347

348 349 350 351 352 353 354 355 356 357 358
    $("#ldap_tmpltype").change(function(){
        switch ($("#ldap_tmpltype").val()) {
            case 'open':
            case 'edir':
              $("#ldap_attr_user").val('cn');
              break;
            case 'msad':
              $("#ldap_attr_user").val('samAccountName');
              break;
        }
    });
359

360 361 362 363 364 365 366 367 368 369 370 371
    $("#radius_srvcs").change(function(){
        switch ($("#radius_srvcs").val()) {
            case 'both': // both
              $("#radius_auth").removeClass('hidden');
              $("#radius_acct").removeClass('hidden');
              break;
            default: // authentication
              $("#radius_auth").removeClass('hidden');
              $("#radius_acct").addClass('hidden');
              break;
        }
    });
372

373 374 375 376
    $(".act_delete").click(function(){
        var id = $(this).attr("id").split('_').pop(-1);
        // delete single
        BootstrapDialog.show({
Fabian Franz's avatar
Fabian Franz committed
377
          type:BootstrapDialog.TYPE_DANGER,
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
          title: "<?= gettext("Server");?>",
          message: "<?=gettext("Do you really want to delete this Server?");?>",
          buttons: [{
                    label: "<?= gettext("No");?>",
                    action: function(dialogRef) {
                        dialogRef.close();
                    }}, {
                    label: "<?= gettext("Yes");?>",
                    action: function(dialogRef) {
                      $("#overview_id").val(id);
                      $("#overview_act").val("del");
                      $("#iform_overview").submit()
                  }
                }]
      });
    });
394

395 396 397 398 399 400 401 402
    // init
    $("#radius_srvcs").change();
    if ($("#ldap_port").val() == "") {
        $("#ldap_urltype").change();
    }
    if ($("#ldap_attr_user").val() == "") {
        $("#ldap_tmpltype").change();
    }
403
    $("#type").change();
404 405 406 407 408 409 410 411 412 413 414 415
});
//]]>
</script>

<?php include("fbegin.inc");?>
  <section class="page-content-main">
    <div class="container-fluid">
      <div class="row">
<?php
      if (isset($input_errors) && count($input_errors) > 0) {
          print_input_errors($input_errors);
      }
416
?>
417 418 419
        <section class="col-xs-12">
          <div class="tab-content content-box col-xs-12 table-responsive">
            <?php if ($act == "new" || $act == "edit") :
420
?>
421 422
            <form id="iform" name="iform" action="system_authservers.php" method="post">
              <table class="table table-striped">
423 424 425 426
                <tr>
                  <td width="22%"></td>
                  <td  width="78%" align="right">
                    <small><?=gettext("full help"); ?> </small>
Ad Schellevis's avatar
Ad Schellevis committed
427
                    <i class="fa fa-toggle-off text-danger"  style="cursor: pointer;" id="show_all_help_page" type="button"></i>
428 429
                  </td>
                </tr>
430 431 432 433
                <tr>
                  <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Descriptive name"); ?></td>
                  <td>
<?php if (!isset($id)) :
434
?>
435 436
                    <input name="name" type="text" size="20" value="<?=$pconfig['name'];?>"/>
<?php else :
437
?>
438
                    <strong><?=$pconfig['name'];?></strong>
439
                    <input name="name" type="hidden" value="<?=$pconfig['name'];?>"/>
440
<?php
441
endif; ?>
442 443 444 445 446 447
                  </td>
                </tr>
                <tr>
                  <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Type"); ?></td>
                  <td>
<?php if (!isset($id)) :
448
?>
449
                    <select name='type' id='type' class="selectpicker" data-style="btn-default">
450 451 452
<?php
                    foreach ($auth_server_types as $typename => $typedesc) :
?>
453 454 455
                      <option value="<?=$typename;?>" <?=$pconfig['type'] == $typename ? "selected=\"selected\"" : "";?> >
                        <?=$typedesc;?>
                      </option>
456 457 458 459
<?php
                    endforeach; ?>
                    </select>
<?php
460 461
else :
?>
462 463 464
                    <strong><?=$auth_server_types[$pconfig['type']];?></strong>
                    <input name='type' type='hidden' id='type' value="<?=$pconfig['type'];?>"/>
<?php
465
endif; ?>
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504
                  </td>
                </tr>
                <!-- LDAP -->
                <tr class="auth_ldap hidden">
                  <td><a id="help_for_ldap_host" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Hostname or IP address");?></td>
                  <td>
                    <input name="ldap_host" type="text" id="ldap_host" size="20" value="<?=$pconfig['ldap_host'];?>"/>
                    <div class="hidden" for="help_for_ldap_host">
                      <?= gettext("NOTE: When using SSL, this hostname MUST match the Common Name (CN) of the LDAP server's SSL Certificate."); ?>
                    </div>
                  </td>
                </tr>
                <tr class="auth_ldap hidden">
                  <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Port value");?></td>
                  <td>
                    <input name="ldap_port" type="text" id="ldap_port" size="5" value="<?=$pconfig['ldap_port'];?>"/>
                  </td>
                </tr>
                <tr class="auth_ldap hidden">
                  <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Transport");?></td>
                  <td>
                    <select name='ldap_urltype' id='ldap_urltype' class="formselect selectpicker" data-style="btn-default">
                      <option value="TCP - Standard" data-port="389" <?=$pconfig['ldap_urltype'] == "TCP - Standard" ? "selected=\"selected\"" : "";?>>
                        <?=gettext("TCP - Standard");?>
                      </option>
                      <option value="SSL - Encrypted" data-port="636" <?=$pconfig['ldap_urltype'] == "SSL - Encrypted" ? "selected=\"selected\"" : "";?>>
                        <?=gettext("SSL - Encrypted");?>
                      </option>
                    </select>
                  </td>
                </tr>
                <tr class="auth_ldap hidden">
                  <td><a id="help_for_ldap_caref" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Peer Certificate Authority"); ?></td>
                  <td>
<?php
                    if (count($config['ca'])) :?>
                    <select id='ldap_caref' name='ldap_caref' class="formselect selectpicker" data-style="btn-default">
<?php
                    foreach ($config['ca'] as $ca) :
505
?>
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
                      <option value="<?=$ca['refid'];?>" <?=$pconfig['ldap_caref'] == $ca['refid'] ? "selected=\"selected\"" : "";?>><?=$ca['descr'];?></option>
<?php
                    endforeach; ?>
                    </select>
                    <div class="hidden" for="help_for_ldap_caref">
                      <span><?=gettext("This option is used if 'SSL Encrypted' option is choosen.");?> <br />
                      <?=gettext("It must match with the CA in the AD otherwise problems will arise.");?></span>
                    </div>
<?php
                    else :?>
                    <b><?=gettext('No Certificate Authorities defined.');?></b> <br /><?=gettext('Create one under');?> <a href="system_camanager.php"><?=gettext('System: Certificates');?></a>.
<?php
                    endif; ?>
                  </td>
                </tr>
                <tr class="auth_ldap hidden">
                  <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Protocol version");?></td>
                  <td>
                    <select name='ldap_protver' id='ldap_protver' class="formselect selectpicker" data-style="btn-default">
                      <option value="2" <?=$pconfig['ldap_protver'] == 2 ? "selected=\"selected\"" : "";?>>2</option>
                      <option value="3" <?=$pconfig['ldap_protver'] == 3 ? "selected=\"selected\"" : "";?>>3</option>
                    </select>
                  </td>
                </tr>
                <tr class="auth_ldap hidden">
                  <td><a id="help_for_ldap_binddn" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Bind credentials");?></td>
                  <td>
                    <?=gettext("User DN:");?><br/>
                    <input name="ldap_binddn" type="text" id="ldap_binddn" size="40" value="<?=$pconfig['ldap_binddn'];?>"/>
                    <?=gettext("Password:");?><br/>
                    <input name="ldap_bindpw" type="password" class="formfld pwd" id="ldap_bindpw" size="20" value="<?=$pconfig['ldap_bindpw'];?>"/><br />
                    <div class="hidden" for="help_for_ldap_binddn">
                      <?=gettext("Leave empty to use anonymous binds to resolve distinguished names");?>
                    </div>
                  </td>
                </tr>
                <tr class="auth_ldap hidden">
                  <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Search scope");?></td>
                  <td>
                    <div>
                      <?=gettext("Level:");?><br/>
                      <select name='ldap_scope' id='ldap_scope' class="formselect selectpicker" data-style="btn-default">
                          <option value="one" <?=$pconfig['ldap_scope'] == 'one' ?  "selected=\"selected\"" : "";?>>
                              <?=gettext('One Level');?>
                          </option>
551
                          <option value="subtree" <?=$pconfig['ldap_scope'] == 'subtree' ?  "selected=\"selected\"" : "";?>>
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598
                              <?=gettext('Entire Subtree');?>
                          </option>
                      </select>
                    </div>
                    <div>
                      <?=gettext("Base DN:");?><br/>
                      <input name="ldap_basedn" type="text" id="ldap_basedn" size="40" value="<?=$pconfig['ldap_basedn'];?>"/>
                    </div>
                  </td>
                </tr>
                <tr class="auth_ldap hidden">
                  <td><a id="help_for_ldapauthcontainers" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Authentication containers");?></td>
                  <td>
                    <ul class="list-inline">
                    <li><input name="ldapauthcontainers" type="text" id="ldapauthcontainers" size="40" value="<?=$pconfig['ldap_authcn'];?>"/></li>
                    <li><input type="button" onclick="select_clicked();" class="btn btn-default" value="<?=gettext("Select");?>" /></li>
                    </ul>
                    <br/>
                    <div class="hidden" for="help_for_ldapauthcontainers">
                        <br/><?=gettext("Note: Semi-Colon separated. This will be prepended to the search base dn above or you can specify full container path containing a dc= component.");?>
                        <br /><?=gettext("Example:");?> CN=Users;DC=example,DC=com
                        <br /><?=gettext("Example:");?> OU=Staff;OU=Freelancers
                    </div>
                  </td>
                </tr>
                <tr class="auth_ldap hidden">
                  <td><a id="help_for_ldap_extended_query" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Extended Query");?></td>
                  <td>
                    <input name="ldap_extended_query" type="text" id="ldap_extended_query" size="40" value="<?=$pconfig['ldap_extended_query'];?>"/>
                    <div class="hidden" for="help_for_ldap_extended_query">
                      <?=gettext("Example:");?> &amp;(objectClass=inetOrgPerson)(mail=*@example.com)
                    </div>
                  </td>
                </tr>
<?php if (!isset($id)) :
?>
                <tr class="auth_ldap hidden">
                  <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Initial Template");?></td>
                  <td>
                    <select name='ldap_tmpltype' id='ldap_tmpltype' class="formselect selectpicker" data-style="btn-default">
                      <option value="open"><?=gettext('OpenLDAP');?></option>
                      <option value="msad"><?=gettext('Microsoft AD');?></option>
                      <option value="edir"><?=gettext('Novell eDirectory');?></option>
                    </select>
                  </td>
                </tr>
<?php
599
endif; ?>
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659
                <tr class="auth_ldap hidden">
                  <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("User naming attribute");?></td>
                  <td>
                    <input name="ldap_attr_user" type="text" id="ldap_attr_user" size="20" value="<?=$pconfig['ldap_attr_user'];?>"/>
                  </td>
                </tr>
                <!-- RADIUS -->
                <tr class="auth_radius hidden">
                  <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Hostname or IP address");?></td>
                  <td>
                    <input name="radius_host" type="text" id="radius_host" size="20" value="<?=$pconfig['radius_host'];?>"/>
                  </td>
                </tr>
                <tr class="auth_radius hidden">
                  <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Shared Secret");?></td>
                  <td>
                    <input name="radius_secret" type="password" class="formfld pwd" id="radius_secret" size="20" value="<?=$pconfig['radius_secret'];?>"/>
                  </td>
                </tr>
                <tr class="auth_radius hidden">
                  <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Services offered");?></td>
                  <td>
                    <select name='radius_srvcs' id='radius_srvcs' class="formselect selectpicker" data-style="btn-default">
                      <option value="both" <?=$pconfig['radius_srvcs'] == 'both' ? "selected=\"selected\"" :"";?>>
                        <?=gettext('Authentication and Accounting');?>
                      </option>
                      <option value="auth" <?=$pconfig['radius_srvcs'] == 'auth' ? "selected=\"selected\"" :"";?>>
                        <?=gettext('Authentication');?>
                      </option>
                    </select>
                  </td>
                </tr>
                <tr id="radius_auth" class="auth_radius hidden">
                  <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Authentication port value");?></td>
                  <td>
                    <input name="radius_auth_port" type="text" id="radius_auth_port" size="5" value="<?=$pconfig['radius_auth_port'];?>"/>
                  </td>
                </tr>
                <tr id="radius_acct" class="auth_radius hidden">
                  <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Accounting port value");?></td>
                  <td>
                    <input name="radius_acct_port" type="text" id="radius_acct_port" size="5" value="<?=$pconfig['radius_acct_port'];?>"/>
                  </td>
                </tr>
                <tr class="auth_radius hidden">
                  <td><a id="help_for_radius_timeout" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Authentication Timeout");?></td>
                  <td>
                    <input name="radius_timeout" type="text" id="radius_timeout" size="20" value="<?=$pconfig['radius_timeout'];?>"/>
                    <div class="hidden" for="help_for_radius_timeout">
                      <br /><?= gettext("This value controls how long, in seconds, that the RADIUS server may take to respond to an authentication request.") ?>
                      <br /><?= gettext("If left blank, the default value is 5 seconds.") ?>
                      <br /><br /><?= gettext("NOTE: If you are using an interactive two-factor authentication system, increase this timeout to account for how long it will take the user to receive and enter a token.") ?>
                    </div>
                  </td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td>
                    <input id="submit" name="save" type="submit" class="btn btn-primary" value="<?=gettext("Save");?>" />
<?php if (isset($id)) :
660
?>
661 662
                    <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
<?php
663
endif;?>
664 665 666 667 668
                  </td>
                </tr>
              </table>
            </form>
<?php
669 670
else :
?>
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695
          <form id="iform_overview" method="post">
            <input type="hidden" id="overview_id" name="id">
            <input type="hidden" id="overview_act" name="act">
            <table class="table table-striped table-sort">
              <thead>
                <tr>
                  <th><?=gettext("Server Name");?></th>
                  <th width="25%"><?=gettext("Type");?></th>
                  <th width="35%"><?=gettext("Host Name");?></th>
                  <th width="10%" class="list"></th>
                </tr>
              </thead>
              <tfoot>
                <tr>
                  <td colspan="4">
                    <p>
                      <?=gettext("Additional authentication servers can be added here.");?>
                    </p>
                  </td>
                </tr>
              </tfoot>
              <tbody>
<?php
$i = 0;
              foreach ($a_server as $server) :
696
?>
697 698 699 700 701 702 703 704 705 706 707 708
                <tr>
                  <td><?=$server['name']?></td>
                  <td><?=!empty($auth_server_types[$server['type']]) ? $auth_server_types[$server['type']] : "";;?></td>
                  <td><?=$server['host'];?></td>
                  <td>
                    <?php if ($i < (count($a_server) - 1)) :
?>
                    <a href="system_authservers.php?act=edit&amp;id=<?=$i;?>" class="btn btn-default btn-xs">
                      <span class="glyphicon glyphicon-pencil"></span>
                    </a>
                    &nbsp;
                    <a id="del_<?=$i;?>" title="<?=gettext("delete this server"); ?>" data-toggle="tooltip"  class="act_delete btn btn-default btn-xs">
709
                      <span class="fa fa-trash text-muted"></span>
710 711 712
                    </a>
                  </td>
<?php
713
endif; ?>
714 715 716 717 718 719 720 721
                </tr>
<?php
                $i++;
              endforeach;?>
              </tbody>
            </table>
          </form>
<?php
722
endif; ?>
723 724 725 726 727
        </div>
      </section>
    </div>
  </div>
</section>
728
<?php include("foot.inc");