Commit 4d5f6fd7 authored by ale's avatar ale

Provide the sso ticket using the storage_connect hook

parent 643e23a9
Pipeline #914 passed with stages
in 3 minutes and 6 seconds
......@@ -13,12 +13,13 @@ class sso extends rcube_plugin
{
private $redirect_query;
function init()
function init()
{
$this->add_hook('startup', array($this, 'startup'));
$this->add_hook('authenticate', array($this, 'authenticate'));
$this->add_hook('login_after', array($this, 'login'));
$this->add_hook('logout_after', array($this, 'logout'));
$this->add_hook('storage_connect', array($this, 'storage_connect'));
}
function startup($args)
......@@ -29,14 +30,11 @@ class sso extends rcube_plugin
use it to login.
*/
if (!empty($_SERVER['SSO_USER']) && !empty($_SERVER['SSO_TICKET'])) {
$rcmail = rcmail::get_instance();
$rcmail->add_shutdown_function(array('sso', 'shutdown'));
if (empty($_SESSION['user_id'])) {
$args['action'] = 'login';
$this->redirect_query = $_SERVER['QUERY_STRING'];
} else if (!empty($_SESSION['user_id']) && empty($_SESSION['password']) && !empty($_SERVER['SSO_TICKET'])) {
$_SESSION['password'] = $rcmail->encrypt($_SERVER['SSO_TICKET']);
} else {
$_SESSION['password'] = null;
}
}
......@@ -47,9 +45,7 @@ class sso extends rcube_plugin
{
if (!empty($_SERVER['SSO_USER'])) {
$args['user'] = $_SERVER['SSO_USER'];
if (!empty($_SERVER['SSO_TICKET'])) {
$args['pass'] = $_SERVER['SSO_TICKET'];
}
$args['pass'] = null;
}
$args['cookiecheck'] = false;
......@@ -66,12 +62,6 @@ class sso extends rcube_plugin
header("Location: " . $sso_logout_url, true, 307);
}
function shutdown()
{
// No need to store the SSO ticket in the Roundcube session.
rcmail::get_instance()->session->remove('password');
}
function login($args)
{
if ($this->redirect_query) {
......@@ -80,4 +70,14 @@ class sso extends rcube_plugin
}
return $args;
}
function storage_connect($args)
{
if (!empty($_SERVER['SSO_USER']) && !empty($_SERVER['SSO_TICKET'])) {
$args['user'] = $_SERVER['SSO_USER'];
$args['pass'] = $_SERVER['SSO_TICKET'];
}
return $args;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment