|
|
|
@ -25,6 +25,7 @@ class krb_authentication extends rcube_plugin
|
|
|
|
|
$this->add_hook('login_after', array($this, 'login'));
|
|
|
|
|
$this->add_hook('storage_connect', array($this, 'storage_connect'));
|
|
|
|
|
$this->add_hook('managesieve_connect', array($this, 'managesieve_connect'));
|
|
|
|
|
$this->add_hook('smtp_connect', array($this, 'smtp_connect'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -74,19 +75,41 @@ class krb_authentication extends rcube_plugin
|
|
|
|
|
return $args;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* login_after hook handler
|
|
|
|
|
*/
|
|
|
|
|
function login($args)
|
|
|
|
|
{
|
|
|
|
|
// Redirect to the previous QUERY_STRING
|
|
|
|
|
if ($this->redirect_query) {
|
|
|
|
|
header('Location: ./?' . $this->redirect_query);
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $args;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Storage_connect hook handler
|
|
|
|
|
*/
|
|
|
|
|
function storage_connect($args)
|
|
|
|
|
{
|
|
|
|
|
if (!empty($_SERVER['REMOTE_USER']) && !empty($_SERVER['KRB5CCNAME'])) {
|
|
|
|
|
// Load plugin's config file
|
|
|
|
|
$this->load_config();
|
|
|
|
|
$args['gssapi_context'] = $this->gssapi_context('imap');
|
|
|
|
|
$args['gssapi_cn'] = $_SERVER['KRB5CCNAME'];
|
|
|
|
|
$args['auth_type'] = 'GSSAPI';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$rcmail = rcmail::get_instance();
|
|
|
|
|
$context = $rcmail->config->get('krb_authentication_context');
|
|
|
|
|
return $args;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$args['gssapi_context'] = $context ?: 'imap/kolab.example.org@EXAMPLE.ORG';
|
|
|
|
|
/**
|
|
|
|
|
* managesieve_connect hook handler
|
|
|
|
|
*/
|
|
|
|
|
function managesieve_connect($args)
|
|
|
|
|
{
|
|
|
|
|
if ((!isset($args['auth_type']) || $args['auth_type'] == 'GSSAPI') && !empty($_SERVER['REMOTE_USER']) && !empty($_SERVER['KRB5CCNAME'])) {
|
|
|
|
|
$args['gssapi_context'] = $this->gssapi_context('sieve');
|
|
|
|
|
$args['gssapi_cn'] = $_SERVER['KRB5CCNAME'];
|
|
|
|
|
$args['auth_type'] = 'GSSAPI';
|
|
|
|
|
}
|
|
|
|
@ -95,36 +118,38 @@ class krb_authentication extends rcube_plugin
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* login_after hook handler
|
|
|
|
|
* smtp_connect hook handler
|
|
|
|
|
*/
|
|
|
|
|
function login($args)
|
|
|
|
|
function smtp_connect($args)
|
|
|
|
|
{
|
|
|
|
|
// Redirect to the previous QUERY_STRING
|
|
|
|
|
if ($this->redirect_query) {
|
|
|
|
|
header('Location: ./?' . $this->redirect_query);
|
|
|
|
|
exit;
|
|
|
|
|
if ((!isset($args['smtp_auth_type']) || $args['smtp_auth_type'] == 'GSSAPI') && !empty($_SERVER['REMOTE_USER']) && !empty($_SERVER['KRB5CCNAME'])) {
|
|
|
|
|
$args['gssapi_context'] = $this->gssapi_context('smtp');
|
|
|
|
|
$args['gssapi_cn'] = $_SERVER['KRB5CCNAME'];
|
|
|
|
|
$args['smtp_auth_type'] = 'GSSAPI';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $args;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* managesieve_connect hook handler
|
|
|
|
|
* Returns configured GSSAPI context string
|
|
|
|
|
*/
|
|
|
|
|
function managesieve_connect($args)
|
|
|
|
|
private function gssapi_context($protocol)
|
|
|
|
|
{
|
|
|
|
|
if ((!isset($args['auth_type']) || $args['auth_type'] == 'GSSAPI') && !empty($_SERVER['REMOTE_USER']) && !empty($_SERVER['KRB5CCNAME'])) {
|
|
|
|
|
// Load plugin's config file
|
|
|
|
|
$this->load_config();
|
|
|
|
|
// Load plugin's config file
|
|
|
|
|
$this->load_config();
|
|
|
|
|
|
|
|
|
|
$rcmail = rcmail::get_instance();
|
|
|
|
|
$context = $rcmail->config->get('krb_authentication_context');
|
|
|
|
|
$rcmail = rcmail::get_instance();
|
|
|
|
|
$context = $rcmail->config->get('krb_authentication_context');
|
|
|
|
|
|
|
|
|
|
$args['gssapi_context'] = $context ?: 'imap/kolab.example.org@EXAMPLE.ORG';
|
|
|
|
|
$args['gssapi_cn'] = $_SERVER['KRB5CCNAME'];
|
|
|
|
|
$args['auth_type'] = 'GSSAPI';
|
|
|
|
|
if (is_array($context)) {
|
|
|
|
|
$context = $context[$protocol];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $args;
|
|
|
|
|
if (empty($context)) {
|
|
|
|
|
rcube::raise_error("Empty GSSAPI context ($protocol).", true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $context;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|