Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/Factory/Transport.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ public function create(array $transport)
$auth = [];
}

if (!isset($auth['password'])) {
$hasXoauth2 = isset($auth['xoauth2_token']) &&
$auth['xoauth2_token'] instanceof \Horde\ManageSieve\Password\Xoauth2;

if (!$hasXoauth2 && !isset($auth['password'])) {
$auth['password'] = $registry->getAuthCredential('password');
}
if (!isset($auth['username'])) {
Expand Down
45 changes: 33 additions & 12 deletions lib/Transport/Timsieved.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,39 @@ protected function _connect()
: $this->_params['admin'];

try {
$this->_sieve = new ManageSieve([
'user' => $auth,
'password' => $this->_params['password'],
'host' => $this->_params['hostspec'],
'port' => $this->_params['port'],
'authmethod' => $this->_params['logintype'],
'euser' => $this->_params['euser'],
'secure' => $this->_params['usetls'],
'logger' => $this->_params['debug']
? $injector->getInstance('Horde_Log_Logger')
: null,
]);
// Check if we have XOAUTH2 token
if (isset($this->_params['xoauth2_token']) &&
$this->_params['xoauth2_token'] instanceof \Horde\ManageSieve\Password\Xoauth2) {
// XOAUTH2 authentication - pass token directly
$authMethod = \Horde\ManageSieve\Client::AUTH_XOAUTH2;

$this->_sieve = new ManageSieve([
'user' => $auth,
'xoauth2_token' => $this->_params['xoauth2_token'],
'host' => $this->_params['hostspec'],
'port' => $this->_params['port'],
'authmethod' => $authMethod,
'euser' => $this->_params['euser'],
'secure' => $this->_params['usetls'],
'logger' => $this->_params['debug']
? $injector->getInstance('Horde_Log_Logger')
: null,
]);
} else {
// Normal password authentication
$this->_sieve = new ManageSieve([
'user' => $auth,
'password' => $this->_params['password'],
'host' => $this->_params['hostspec'],
'port' => $this->_params['port'],
'authmethod' => $this->_params['logintype'],
'euser' => $this->_params['euser'],
'secure' => $this->_params['usetls'],
'logger' => $this->_params['debug']
? $injector->getInstance('Horde_Log_Logger')
: null,
]);
}
} catch (ManageSieveException $e) {
throw new Ingo_Exception($e);
}
Expand Down
Loading