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/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 */
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
*
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