Projet

Général

Profil

Télécharger (4,45 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / diag_authentication.php @ 1ec21686

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

    
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 .= "<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

    
75
<body link="#000000" vlink="#000000" alink="#000000">
76

    
77
<?php include("fbegin.inc"); ?>
78
<?php if ($input_errors) print_input_errors($input_errors);?>
79
<?php if ($savemsg) print_info_box($savemsg);?>
80

    
81
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="diag authentication">
82
	<tr>
83
		<td class="tabnavtbl"></td>
84
	</tr>
85
	<tr>
86
	<td>
87
	<div id="mainarea">
88
	<form id="iform" name="iform" action="diag_authentication.php" method="post">
89
	<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6" summary="test">
90
	<tr>
91
		<td width="22%" valign="top" class="vncell"><?=gettext("Authentication Server"); ?></td>
92
		<td width="78%" class="vtable">
93
			<select name="authmode" id="authmode" class="formselect" >
94
			<?php
95
				$auth_servers = auth_get_authserver_list();
96
				foreach ($auth_servers as $auth_server):
97
					$selected = "";
98
					if ($auth_server['name'] == $pconfig['authmode'])
99
						$selected = "selected=\"selected\"";
100
			?>
101
			<option value="<?=$auth_server['name'];?>" <?=$selected;?>><?=$auth_server['name'];?></option>
102
			<?php   endforeach; ?>
103
			</select>
104
		</td>
105
	</tr>
106
	<tr>
107
		<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
108
		<td width="78%" class="vtable">
109
			<input class="formfld unknown" size="20" id="username" name="username" value="<?=htmlspecialchars($pconfig['username']);?>" />
110
		</td>
111
	</tr>
112
	<tr>
113
		<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
114
		<td width="78%" class="vtable">
115
			<input class="formfld pwd" type="password" size="20" id="password" name="password" value="<?=htmlspecialchars($pconfig['password']);?>" />
116
		</td>
117
	</tr>
118
	<tr>
119
		<td width="22%" valign="top">&nbsp;</td>
120
		<td width="78%">
121
			<input id="save" name="save" type="submit" class="formbtn" value="<?=gettext("Test");?>" />
122
		</td>
123
	</tr>
124
	</table>
125
	</form>
126
	</div>
127
	</td></tr>
128
</table>
129

    
130
<?php include("fend.inc"); ?>
131
</body>
132
</html>
(6-6/254)