1
|
<?php
|
2
|
/*
|
3
|
diag_authentication.php
|
4
|
part of the pfSense project (https://www.pfsense.org)
|
5
|
Copyright (C) 2010 Ermal Luçi
|
6
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
7
|
All rights reserved.
|
8
|
|
9
|
Redistribution and use in source and binary forms, with or without
|
10
|
modification, are permitted provided that the following conditions are met:
|
11
|
|
12
|
1. Redistributions of source code must retain the above copyright notice,
|
13
|
this list of conditions and the following disclaimer.
|
14
|
|
15
|
2. Redistributions in binary form must reproduce the above copyright
|
16
|
notice, this list of conditions and the following disclaimer in the
|
17
|
documentation and/or other materials provided with the distribution.
|
18
|
|
19
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
20
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
21
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
22
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
23
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28
|
POSSIBILITY OF SUCH DAMAGE.
|
29
|
*/
|
30
|
|
31
|
/*
|
32
|
pfSense_MODULE: auth
|
33
|
*/
|
34
|
|
35
|
##|+PRIV
|
36
|
##|*IDENT=page-diagnostics-authentication
|
37
|
##|*NAME=Diagnostics: Authentication page
|
38
|
##|*DESCR=Allow access to the 'Diagnostics: Authentication' page.
|
39
|
##|*MATCH=diag_authentication.php*
|
40
|
##|-PRIV
|
41
|
|
42
|
require("guiconfig.inc");
|
43
|
require_once("PEAR.inc");
|
44
|
require_once("radius.inc");
|
45
|
|
46
|
if ($_POST) {
|
47
|
$pconfig = $_POST;
|
48
|
unset($input_errors);
|
49
|
|
50
|
$authcfg = auth_get_authserver($_POST['authmode']);
|
51
|
if (!$authcfg)
|
52
|
$input_errors[] = $_POST['authmode'] . " " . gettext("is not a valid authentication server");
|
53
|
|
54
|
if (empty($_POST['username']) || empty($_POST['passwordfld']))
|
55
|
$input_errors[] = gettext("A username and password must be specified.");
|
56
|
|
57
|
if (!$input_errors) {
|
58
|
if (authenticate_user($_POST['username'], $_POST['passwordfld'], $authcfg)) {
|
59
|
$savemsg = gettext("User") . ": " . $_POST['username'] . " " . gettext("authenticated successfully.");
|
60
|
$groups = getUserGroups($_POST['username'], $authcfg);
|
61
|
$savemsg .= "<br />" . gettext("This user is a member of these groups") . ": <br />";
|
62
|
foreach ($groups as $group)
|
63
|
$savemsg .= "{$group} ";
|
64
|
} else {
|
65
|
$input_errors[] = gettext("Authentication failed.");
|
66
|
}
|
67
|
}
|
68
|
}
|
69
|
$pgtitle = array(gettext("Diagnostics"),gettext("Authentication"));
|
70
|
$shortcut_section = "authentication";
|
71
|
include("head.inc");
|
72
|
|
73
|
?>
|
74
|
<?php if ($input_errors) print_input_errors($input_errors)?>
|
75
|
<?php if ($savemsg) print_info_box($savemsg)?>
|
76
|
<div id="container">
|
77
|
<form class="form-horizontal" action="diag_authentication.php" method="post">
|
78
|
<div class="form-group">
|
79
|
<label for="authmode" class="col-sm-2 control-label"><?=gettext("Authentication Server")?></label>
|
80
|
<div class="col-sm-10">
|
81
|
<select name="authmode" id="authmode" class="formselect" >
|
82
|
<?php
|
83
|
foreach (auth_get_authserver_list() as $auth_server):
|
84
|
$selected = ($auth_server['name'] == $pconfig['authmode'])
|
85
|
?>
|
86
|
<option value="<?=$auth_server['name']?>" <?=($selected?'selected="selected"':'')?>>
|
87
|
<?=$auth_server['name']?>
|
88
|
</option>
|
89
|
<?php endforeach?>
|
90
|
</select>
|
91
|
</div>
|
92
|
</div>
|
93
|
|
94
|
<div class="form-group">
|
95
|
<label for="authmode" class="col-sm-2 control-label"><?=gettext("Username")?></label>
|
96
|
<div class="col-sm-10">
|
97
|
<input name="username" value="<?=htmlspecialchars($pconfig['username'])?>" />
|
98
|
</div>
|
99
|
</div>
|
100
|
|
101
|
<div class="form-group">
|
102
|
<label for="authmode" class="col-sm-2 control-label"><?=gettext("Password")?></label>
|
103
|
<div class="col-sm-10">
|
104
|
<input name="password" type="password" value="<?=htmlspecialchars($pconfig['password'])?>" />
|
105
|
</div>
|
106
|
</div>
|
107
|
|
108
|
<button type="submit" class="btn btn-primary"><?=gettext("Test");?></button>
|
109
|
</form>
|
110
|
</div>
|
111
|
</div>
|
112
|
<?php include("foot.inc")?>
|