1 |
3f0357fc
|
Ermal Lu?i
|
<?php
|
2 |
|
|
/*
|
3 |
939cc57a
|
Warren Baker
|
diag_authentication.php
|
4 |
45d6ada5
|
Sjon Hortensius
|
part of the pfSense project (https://www.pfsense.org)
|
5 |
1d7ba683
|
ayvis
|
Copyright (C) 2010 Ermal Luçi
|
6 |
ce77a9c4
|
Phil Davis
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
7 |
3f0357fc
|
Ermal Lu?i
|
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 |
45d6ada5
|
Sjon Hortensius
|
pfSense_MODULE: auth
|
33 |
3f0357fc
|
Ermal Lu?i
|
*/
|
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 |
6e815096
|
Ermal
|
require_once("PEAR.inc");
|
44 |
|
|
require_once("radius.inc");
|
45 |
3f0357fc
|
Ermal Lu?i
|
|
46 |
|
|
if ($_POST) {
|
47 |
|
|
$pconfig = $_POST;
|
48 |
|
|
unset($input_errors);
|
49 |
|
|
|
50 |
|
|
$authcfg = auth_get_authserver($_POST['authmode']);
|
51 |
|
|
if (!$authcfg)
|
52 |
f8ec8de4
|
Renato Botelho
|
$input_errors[] = $_POST['authmode'] . " " . gettext("is not a valid authentication server");
|
53 |
3f0357fc
|
Ermal Lu?i
|
|
54 |
45d6ada5
|
Sjon Hortensius
|
if (empty($_POST['username']) || empty($_POST['password']))
|
55 |
f8ec8de4
|
Renato Botelho
|
$input_errors[] = gettext("A username and password must be specified.");
|
56 |
3f0357fc
|
Ermal Lu?i
|
|
57 |
|
|
if (!$input_errors) {
|
58 |
45d6ada5
|
Sjon Hortensius
|
if (authenticate_user($_POST['username'], $_POST['password'], $authcfg)) {
|
59 |
3f178953
|
Erik Fonnesbeck
|
$savemsg = gettext("User") . ": " . $_POST['username'] . " " . gettext("authenticated successfully.");
|
60 |
fb0f22c0
|
Ermal Lu?i
|
$groups = getUserGroups($_POST['username'], $authcfg);
|
61 |
45d6ada5
|
Sjon Hortensius
|
$savemsg .= " " . gettext("This user is a member of groups") . ": <br />";
|
62 |
|
|
$savemsg .= "<ul>";
|
63 |
fb0f22c0
|
Ermal Lu?i
|
foreach ($groups as $group)
|
64 |
45d6ada5
|
Sjon Hortensius
|
$savemsg .= "<li>" . "{$group} " . "</li>";
|
65 |
|
|
$savemsg .= "</ul>";
|
66 |
|
|
|
67 |
fb0f22c0
|
Ermal Lu?i
|
} else {
|
68 |
f8ec8de4
|
Renato Botelho
|
$input_errors[] = gettext("Authentication failed.");
|
69 |
fb0f22c0
|
Ermal Lu?i
|
}
|
70 |
3f0357fc
|
Ermal Lu?i
|
}
|
71 |
|
|
}
|
72 |
f8ec8de4
|
Renato Botelho
|
$pgtitle = array(gettext("Diagnostics"),gettext("Authentication"));
|
73 |
d71fc5d3
|
jim-p
|
$shortcut_section = "authentication";
|
74 |
3f0357fc
|
Ermal Lu?i
|
include("head.inc");
|
75 |
|
|
|
76 |
|
|
?>
|
77 |
45d6ada5
|
Sjon Hortensius
|
<?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 |
38e06c66
|
Sjon Hortensius
|
$form = new Form('Test'));
|
87 |
45d6ada5
|
Sjon Hortensius
|
|
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");
|