From db07b65c657162ce04c50ec1164390f0fb68b905 Mon Sep 17 00:00:00 2001 From: Piotr Przybylski Date: Mon, 6 Jun 2011 16:40:43 +0200 Subject: [PATCH 1/3] Add missing 'server' argument to PMA_reloadRecentTable Was causing token regeneration on non-default servers, if the next action required valid token it would fail --- js/navigation.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/js/navigation.js b/js/navigation.js index 7f9a013119..20aea18bd4 100644 --- a/js/navigation.js +++ b/js/navigation.js @@ -171,13 +171,16 @@ function clear_fast_filter() { * Reloads the recent tables list. */ function PMA_reloadRecentTable() { - $.get('navigation.php', - { 'token' : window.parent.token, 'ajax_request' : true, 'recent_table' : true }, - function (data) { - if (data.success == true) { - $('#recentTable').html(data.options); - } - }); + $.get('navigation.php', { + 'token': window.parent.token, + 'server': window.parent.server, + 'ajax_request': true, + 'recent_table': true}, + function (data) { + if (data.success == true) { + $('#recentTable').html(data.options); + } + }); } /* Performed on load */ From 72886c3c8a6cf2a01ea40f01c7d7c4c981a3a4e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 6 Jun 2011 17:08:02 +0200 Subject: [PATCH 2/3] Add option to call extenal script from signon method --- Documentation.html | 28 +++++++++++++++++++++------- libraries/auth/signon.auth.lib.php | 14 +++++++++++++- libraries/config.default.php | 7 +++++++ 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/Documentation.html b/Documentation.html index 6e987473e0..6f66b64828 100644 --- a/Documentation.html +++ b/Documentation.html @@ -759,13 +759,17 @@ since this link provides funding for phpMyAdmin.
  • 'signon' authentication mode ($auth_type = 'signon') as introduced in 2.10.0 allows you to log in from prepared PHP - session data. This is useful for implementing single signon - from another application. Sample way how to seed session is in - signon example: scripts/signon.php. There is also - alternative example using OpenID - - scripts/openid.php. You need to + session data or using supplied PHP script. This is useful for implementing single signon + from another application. + + Sample way how to seed session is in signon example: scripts/signon.php. + There is also alternative example using OpenID - scripts/openid.php and + example for scripts based solution - scripts/signon-script.php. + + You need to configure session name and session name or script to be executed and signon URL to use this authentication method.
  • @@ -1320,10 +1324,20 @@ CREATE DATABASE,ALTER DATABASE,DROP DATABASE
    $cfg['Servers'][$i]['CountTables'] boolean
    Whether to count the number of tables for each database when preparing the list of databases for the navigation frame.
    +
    $cfg['Servers'][$i]['SignonScript'] string
    +
    Name of PHP script to be sourced and executed to obtain + login credentials. This is alternative approach to session based single + signon. The script needs to provide function + get_login_credentials which returns list of username and + pasword, accepting single parameter of existing username (can be empty). + See scripts/signon-script.php for an example. +
    $cfg['Servers'][$i]['SignonSession'] string
    Name of session which will be used for signon authentication method. You should use something different than phpMyAdmin, because - this is session which phpMyAdmin uses internally. + this is session which phpMyAdmin uses internally. Takes effect only if + SignonScript + is not configured.
    $cfg['Servers'][$i]['SignonURL'] string
    URL where user will be redirected to log in for signon authentication method. Should be absolute including protocol. diff --git a/libraries/auth/signon.auth.lib.php b/libraries/auth/signon.auth.lib.php index 0735020f4a..e095829936 100644 --- a/libraries/auth/signon.auth.lib.php +++ b/libraries/auth/signon.auth.lib.php @@ -60,6 +60,9 @@ function PMA_auth_check() return false; } + /* Script name */ + $script_name = $GLOBALS['cfg']['Server']['SignonScript']; + /* Session name */ $session_name = $GLOBALS['cfg']['Server']['SignonSession']; @@ -78,8 +81,17 @@ function PMA_auth_check() /* Are we requested to do logout? */ $do_logout = !empty($_REQUEST['old_usr']); + /* Handle script based auth */ + if (!empty($script_name)) { + if (! file_exists($script_name)) { + PMA_fatalError(__('Can not find signon authentication script:') . ' ' . $script_name); + } + require $script_name; + + list ($PHP_AUTH_USER, $PHP_AUTH_PW) = get_login_credentials($cfg['Server']['user']); + /* Does session exist? */ - if (isset($_COOKIE[$session_name])) { + } elseif (isset($_COOKIE[$session_name])) { /* End current session */ $old_session = session_name(); $old_id = session_id(); diff --git a/libraries/config.default.php b/libraries/config.default.php index d6e47c2720..1a478b7874 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -212,6 +212,13 @@ $cfg['Servers'][$i]['password'] = ''; */ $cfg['Servers'][$i]['SignonSession'] = ''; +/** + * PHP script to use for 'signon' authentication method + * + * @global string $cfg['Servers'][$i]['SignonScript'] + */ +$cfg['Servers'][$i]['SignonScript'] = ''; + /** * URL where to redirect user to login for 'signon' authentication method * From cf6312f5278f922ab420d501200b175eba987c5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 6 Jun 2011 17:08:35 +0200 Subject: [PATCH 3/3] Clarify documentation --- scripts/signon.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/signon.php b/scripts/signon.php index e585625db9..d80c1cf9de 100644 --- a/scripts/signon.php +++ b/scripts/signon.php @@ -3,9 +3,9 @@ /** * Single signon for phpMyAdmin * - * This is just example how to use single signon with phpMyAdmin, it is - * not intended to be perfect code and look, only shows how you can - * integrate this functionality in your application. + * This is just example how to use session based single signon with + * phpMyAdmin, it is not intended to be perfect code and look, only + * shows how you can integrate this functionality in your application. * * @package phpMyAdmin * @subpackage Example