Project

General

Profile

« Previous | Next » 

Revision ed3f295a

Added by sbeaver over 10 years ago

Conversion completed

View differences:

usr/local/www/diag_authentication.php
1 1
<?php
2 2
/*
3 3
	diag_authentication.php
4
	part of the pfSense project	(https://www.pfsense.org)
4
	part of the pfSense project (https://www.pfsense.org)
5 5
	Copyright (C) 2010 Ermal Luçi
6 6
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
7 7
	All rights reserved.
......
29 29
*/
30 30

  
31 31
/*
32
	pfSense_MODULE:	auth
32
	pfSense_MODULE: auth
33 33
*/
34 34

  
35 35
##|+PRIV
......
51 51
	if (!$authcfg)
52 52
		$input_errors[] = $_POST['authmode'] . " " . gettext("is not a valid authentication server");
53 53

  
54
	if (empty($_POST['username']) || empty($_POST['passwordfld']))
54
	if (empty($_POST['username']) || empty($_POST['password']))
55 55
		$input_errors[] = gettext("A username and password must be specified.");
56 56

  
57 57
	if (!$input_errors) {
58
		if (authenticate_user($_POST['username'], $_POST['passwordfld'], $authcfg)) {
58
		if (authenticate_user($_POST['username'], $_POST['password'], $authcfg)) {
59 59
			$savemsg = gettext("User") . ": " . $_POST['username'] . " " . gettext("authenticated successfully.");
60 60
			$groups = getUserGroups($_POST['username'], $authcfg);
61
			$savemsg .= "<br />" . gettext("This user is a member of these groups") . ": <br />";
61
			$savemsg .= "&nbsp;" . gettext("This user is a member of groups") . ": <br />";
62
			$savemsg .= "<ul>";
62 63
			foreach ($groups as $group)
63
				$savemsg .= "{$group} ";
64
				$savemsg .= "<li>" . "{$group} " . "</li>";
65
			$savemsg .= "</ul>";
66

  
64 67
		} else {
65 68
			$input_errors[] = gettext("Authentication failed.");
66 69
		}
......
71 74
include("head.inc");
72 75

  
73 76
?>
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")?>
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(new Form_Button(
87
	'Submit',
88
	gettext('Test')
89
));
90

  
91
$section = new Form_Section('Authentication Test');
92

  
93
foreach (auth_get_authserver_list() as $auth_server)
94
	$serverlist[$auth_server['name']] = $auth_server['name'];
95

  
96
$section->addInput(new Form_Select(
97
	'authmode',
98
	'Authentication Server',
99
	$pconfig['authmode'],
100
	$serverlist
101
))->setHelp('Select the authentication server to test against');
102

  
103
$section->addInput(new Form_Input(
104
	'username',
105
	'Username',
106
	'text',
107
	htmlspecialchars($pconfig['username']),
108
	['placeholder' => 'Username']
109
));
110

  
111
$section->addInput(new Form_Input(
112
	'password',
113
	'Pasword',
114
	'text',
115
	htmlspecialchars($pconfig['password']),
116
	['placeholder' => 'Password']
117
));
118

  
119
$form->add($section);
120
print $form;
121

  
122
include("foot.inc")
123
?>

Also available in: Unified diff