Project

General

Profile

Download (4.82 KB) Statistics
| Branch: | Tag: | Revision:
1 3f0357fc Ermal Lu?i
<?php
2
/*
3 939cc57a Warren Baker
	diag_authentication.php
4 c7281770 Chris Buechler
	part of the pfSense project	(https://www.pfsense.org)
5 1d7ba683 ayvis
	Copyright (C) 2010 Ermal Luçi
6 6317d31d 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
	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 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 39dff8e2 Phil Davis
	if (empty($_POST['username']) || empty($_POST['passwordfld']))
55 f8ec8de4 Renato Botelho
		$input_errors[] = gettext("A username and password must be specified.");
56 3f0357fc Ermal Lu?i
57
	if (!$input_errors) {
58 709c2f99 jim-p
		$attributes = array();
59
		if (authenticate_user($_POST['username'], $_POST['passwordfld'], $authcfg, $attributes)) {
60 3f178953 Erik Fonnesbeck
			$savemsg = gettext("User") . ": " . $_POST['username'] . " " . gettext("authenticated successfully.");
61 709c2f99 jim-p
			$groups = getUserGroups($_POST['username'], $authcfg, $attributes);
62 3f178953 Erik Fonnesbeck
			$savemsg .= "<br />" . gettext("This user is a member of these groups") . ": <br />";
63 fb0f22c0 Ermal Lu?i
			foreach ($groups as $group)
64
				$savemsg .= "{$group} ";
65
		} else {
66 f8ec8de4 Renato Botelho
			$input_errors[] = gettext("Authentication failed.");
67 fb0f22c0 Ermal Lu?i
		}
68 3f0357fc Ermal Lu?i
	}
69 08d6f8ff Phil Davis
} else {
70
	// Choose a reasonable initial default.
71
	if (isset($config['system']['webgui']['authmode'])) {
72
		$pconfig['authmode'] = $config['system']['webgui']['authmode'];
73
	}
74
	else {
75
		$pconfig['authmode'] = "Local Database";
76
	}
77 3f0357fc Ermal Lu?i
}
78 f8ec8de4 Renato Botelho
$pgtitle = array(gettext("Diagnostics"),gettext("Authentication"));
79 d71fc5d3 jim-p
$shortcut_section = "authentication";
80 3f0357fc Ermal Lu?i
include("head.inc");
81
82
?>
83
84 6db7ee23 xbipin
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
85 f8ec8de4 Renato Botelho
86 3f0357fc Ermal Lu?i
<?php include("fbegin.inc"); ?>
87
<?php if ($input_errors) print_input_errors($input_errors);?>
88
<?php if ($savemsg) print_info_box($savemsg);?>
89
90 1ec21686 Colin Fleming
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="diag authentication">
91 3f0357fc Ermal Lu?i
	<tr>
92
		<td class="tabnavtbl"></td>
93
	</tr>
94
	<tr>
95
	<td>
96
	<div id="mainarea">
97
	<form id="iform" name="iform" action="diag_authentication.php" method="post">
98 1ec21686 Colin Fleming
	<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6" summary="test">
99 3f0357fc Ermal Lu?i
	<tr>
100 f8ec8de4 Renato Botelho
		<td width="22%" valign="top" class="vncell"><?=gettext("Authentication Server"); ?></td>
101 3f0357fc Ermal Lu?i
		<td width="78%" class="vtable">
102 1ec21686 Colin Fleming
			<select name="authmode" id="authmode" class="formselect" >
103 3f0357fc Ermal Lu?i
			<?php
104
				$auth_servers = auth_get_authserver_list();
105
				foreach ($auth_servers as $auth_server):
106
					$selected = "";
107
					if ($auth_server['name'] == $pconfig['authmode'])
108 1ec21686 Colin Fleming
						$selected = "selected=\"selected\"";
109 3f0357fc Ermal Lu?i
			?>
110 64c50ecd jim-p
			<option value="<?=htmlspecialchars($auth_server['name']);?>" <?=$selected;?>><?=htmlspecialchars($auth_server['name']);?></option>
111 3f0357fc Ermal Lu?i
			<?php   endforeach; ?>
112
			</select>
113
		</td>
114
	</tr>
115
	<tr>
116 f8ec8de4 Renato Botelho
		<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
117 3f0357fc Ermal Lu?i
		<td width="78%" class="vtable">
118 1ec21686 Colin Fleming
			<input class="formfld unknown" size="20" id="username" name="username" value="<?=htmlspecialchars($pconfig['username']);?>" />
119 3f0357fc Ermal Lu?i
		</td>
120
	</tr>
121
	<tr>
122 f8ec8de4 Renato Botelho
		<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
123 3f0357fc Ermal Lu?i
		<td width="78%" class="vtable">
124 39dff8e2 Phil Davis
			<input class="formfld pwd" type="password" size="20" id="passwordfld" name="passwordfld" value="<?=htmlspecialchars($pconfig['passwordfld']);?>" />
125 3f0357fc Ermal Lu?i
		</td>
126
	</tr>
127
	<tr>
128
		<td width="22%" valign="top">&nbsp;</td>
129
		<td width="78%">
130 335f296f Chris Buechler
			<input id="save" name="save" type="submit" class="formbtn" value="<?=gettext("Test");?>" />
131 3f0357fc Ermal Lu?i
		</td>
132
	</tr>
133
	</table>
134 1ec21686 Colin Fleming
	</form>
135
	</div>
136 3f0357fc Ermal Lu?i
	</td></tr>
137
</table>
138
139
<?php include("fend.inc"); ?>
140 1ec21686 Colin Fleming
</body>
141
</html>