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['password']))
|
55
|
$input_errors[] = gettext("A username and password must be specified.");
|
56
|
|
57
|
if (!$input_errors) {
|
58
|
if (authenticate_user($_POST['username'], $_POST['password'], $authcfg)) {
|
59
|
$savemsg = gettext("User") . ": " . $_POST['username'] . " " . gettext("authenticated successfully.");
|
60
|
$groups = getUserGroups($_POST['username'], $authcfg);
|
61
|
$savemsg .= " " . gettext("This user is a member of groups") . ": <br />";
|
62
|
$savemsg .= "<ul>";
|
63
|
foreach ($groups as $group)
|
64
|
$savemsg .= "<li>" . "{$group} " . "</li>";
|
65
|
$savemsg .= "</ul>";
|
66
|
|
67
|
} else {
|
68
|
$input_errors[] = gettext("Authentication failed.");
|
69
|
}
|
70
|
}
|
71
|
}
|
72
|
$pgtitle = array(gettext("Diagnostics"),gettext("Authentication"));
|
73
|
$shortcut_section = "authentication";
|
74
|
include("head.inc");
|
75
|
|
76
|
?>
|
77
|
<?php
|
78
|
if ($input_errors)
|
79
|
print_input_errors($input_errors);
|
80
|
|
81
|
if ($savemsg)
|
82
|
print('<div class="alert alert-success" role="alert">'. $savemsg.'</div>');
|
83
|
|
84
|
require('classes/Form.class.php');
|
85
|
|
86
|
$form = new Form('Test'));
|
87
|
|
88
|
$section = new Form_Section('Authentication Test');
|
89
|
|
90
|
foreach (auth_get_authserver_list() as $auth_server)
|
91
|
$serverlist[$auth_server['name']] = $auth_server['name'];
|
92
|
|
93
|
$section->addInput(new Form_Select(
|
94
|
'authmode',
|
95
|
'Authentication Server',
|
96
|
$pconfig['authmode'],
|
97
|
$serverlist
|
98
|
))->setHelp('Select the authentication server to test against');
|
99
|
|
100
|
$section->addInput(new Form_Input(
|
101
|
'username',
|
102
|
'Username',
|
103
|
'text',
|
104
|
$pconfig['username'],
|
105
|
['placeholder' => 'Username']
|
106
|
));
|
107
|
|
108
|
$section->addInput(new Form_Input(
|
109
|
'password',
|
110
|
'Password',
|
111
|
'password',
|
112
|
$pconfig['password'],
|
113
|
['placeholder' => 'Password']
|
114
|
));
|
115
|
|
116
|
$form->add($section);
|
117
|
print $form;
|
118
|
|
119
|
include("foot.inc");
|