Add single signon authentication method (patch #1545366, patch #1541379, patch #1531302 and RFE #1031391).

This commit is contained in:
Michal Čihař
2006-08-24 12:38:29 +00:00
parent 22bb5059e2
commit 862bc35be7
6 changed files with 258 additions and 3 deletions

View File

@@ -938,7 +938,7 @@ function show_server_form($defaults = array(), $number = FALSE) {
array('Connection type', 'connect_type', 'How to connect to server, keep tcp if unsure', array('tcp', 'socket')),
array('PHP extension to use', 'extension', 'What PHP extension to use, use mysqli if supported', array('mysql', 'mysqli')),
array('Compress connection', 'compress', 'Whether to compress connection to MySQL server', FALSE),
array('Authentication type', 'auth_type', 'Authentication method to use', array('cookie', 'http', 'config')),
array('Authentication type', 'auth_type', 'Authentication method to use', array('cookie', 'http', 'config', 'signon')),
array('User for config auth', 'user', 'Leave empty if not using config auth'),
array('Password for config auth', 'password', 'Leave empty if not using config auth', 'password'),
array('Only database to show', 'only_db', 'Limit listing of databases in left frame to this one'),
@@ -946,6 +946,9 @@ function show_server_form($defaults = array(), $number = FALSE) {
array('phpMyAdmin control user', 'controluser', 'User which phpMyAdmin can use for various actions'),
array('phpMyAdmin control user password', 'controlpass', 'Password for user which phpMyAdmin can use for various actions', 'password'),
array('phpMyAdmin database for advanced features', 'pmadb', 'phpMyAdmin will allow much more when you enable this. Table names are filled in automatically.'),
array('Session name for signon auth', 'SignonSession', 'Leave empty if not using signon auth'),
array('Login URL for signon auth', 'SignonURL', 'Leave empty if not using signon auth'),
array('Logout URL', 'LogoutURL', 'Where to redirect user after logout'),
),
'Configure server',
($number === FALSE) ? 'Enter new server connection parameters.' : 'Editing server ' . get_server_name($defaults, $number),
@@ -1276,7 +1279,7 @@ switch ($action) {
case 'addserver_real':
if (isset($_POST['submit_save'])) {
$new_server = grab_values('host;extension;port;socket;connect_type;compress:bool;controluser;controlpass;auth_type;user;password;only_db;verbose;pmadb;bookmarktable:serialized;relation:serialized;table_info:serialized;table_coords:serialized;pdf_pages:serialized;column_info:serialized;history:serialized;AllowDeny:serialized');
$new_server = grab_values('host;extension;port;socket;connect_type;compress:bool;controluser;controlpass;auth_type;user;password;only_db;verbose;pmadb;bookmarktable:serialized;relation:serialized;table_info:serialized;table_coords:serialized;pdf_pages:serialized;column_info:serialized;history:serialized;AllowDeny:serialized;SignonSession;SignonURL;LogoutURL');
$err = FALSE;
if (empty($new_server['host'])) {
message('error', 'Empty hostname!');
@@ -1286,6 +1289,14 @@ switch ($action) {
message('error', 'Empty username while using config authentication method!');
$err = TRUE;
}
if ($new_server['auth_type'] == 'signon' && empty($new_server['SignonSession'])) {
message('error', 'Empty signon session name while using signon authentication method!');
$err = TRUE;
}
if ($new_server['auth_type'] == 'signon' && empty($new_server['SignonURL'])) {
message('error', 'Empty signon URL while using signon authentication method!');
$err = TRUE;
}
if ( isset($new_server['pmadb']) && strlen($new_server['pmadb'])) {
// Just use defaults, should be okay for most users
$pmadb = array();

50
scripts/signon.php Normal file
View File

@@ -0,0 +1,50 @@
<?php
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
// Single signon for phpMyAdmin
//
// This is just example how to use signle signon with phpMyAdmin, it is
// not intented to be perfect code and look, only shows how you can
// integrate this functionality in your application.
/* Was data posted? */
if (isset($_POST['user'])) {
/* Need to have cookie visible from parent directory */
session_set_cookie_params(0, '/', '', 0);
/* Create signon session */
$session_name = 'SignonSession';
session_name($session_name);
session_start();
/* Store there credentials */
$_SESSION['PMA_single_signon_user'] = $_POST['user'];
$_SESSION['PMA_single_signon_password'] = $_POST['password'];
$id = session_id();
/* Close that session */
session_write_close();
/* Redirect to phpMyAdmin (should use absolute URL here!) */
header('Location: ../index.php');
} else {
/* Show simple form */
header('Content-Type: text/html; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<link rel="icon" href="../favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<title>phpMyAdmin signle signon example</title>
<html>
<body>
<form action="signon.php" method="post">
Username: <input type="text" name="user" /><br />
Password: <input type="password" name="password" /><br />
<input type="submit" />
</form>
</body>
</html>
<?php
}
?>