SMTP GSSAPI support (#6417)

* krb_authentication support for smtp_connect
* smtp GSSAPI support
pull/328/merge
urusha 6 years ago committed by Aleksander Machniak
parent e38b477b99
commit 75f37f8b0f

@ -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'));
}
/**
@ -127,4 +128,24 @@ class krb_authentication extends rcube_plugin
return $args;
}
/**
* smtp_connect hook handler
*/
function smtp_connect($args)
{
if ((!isset($args['smtp_auth_type']) || $args['smtp_auth_type'] == 'GSSAPI') && !empty($_SERVER['REMOTE_USER']) && !empty($_SERVER['KRB5CCNAME'])) {
// Load plugin's config file
$this->load_config();
$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['smtp_auth_type'] = 'GSSAPI';
}
return $args;
}
}

@ -108,7 +108,8 @@ class rcube_smtp
// IDNA Support
$smtp_host = rcube_utils::idn_to_ascii($smtp_host);
$this->conn = new Net_SMTP($smtp_host, $smtp_port, $helo_host, false, 0, $CONFIG['smtp_conn_options']);
$this->conn = new Net_SMTP($smtp_host, $smtp_port, $helo_host, false, 0, $CONFIG['smtp_conn_options'],
$CONFIG['gssapi_context'], $CONFIG['gssapi_cn']);
if ($rcube->config->get('smtp_debug')) {
$this->conn->setDebug(true, array($this, 'debug_handler'));
@ -154,7 +155,7 @@ class rcube_smtp
}
// attempt to authenticate to the SMTP server
if ($smtp_user && $smtp_pass) {
if (($smtp_user && $smtp_pass) || ($smtp_auth_type == 'GSSAPI')) {
// IDNA Support
if (strpos($smtp_user, '@')) {
$smtp_user = rcube_utils::idn_to_ascii($smtp_user);

Loading…
Cancel
Save