Sieve support login with OAUTHBEARER/XOAUTH2

This commit is contained in:
djmaze 2021-10-22 15:31:56 +02:00
parent ed109740cd
commit 89f0e81194

View file

@ -115,6 +115,8 @@ class ManageSieveClient extends \MailSo\Net\NetClient
// 'SCRAM-SHA-256' => 1, // !$encrypted // 'SCRAM-SHA-256' => 1, // !$encrypted
// 'SCRAM-SHA-1' => 1, // !$encrypted // 'SCRAM-SHA-1' => 1, // !$encrypted
// 'CRAM-MD5' => 1, // $encrypted // 'CRAM-MD5' => 1, // $encrypted
'OAUTHBEARER' => $aCredentials['UseAuthOAuth2IfSupported'],
'XOAUTH2' => $aCredentials['UseAuthOAuth2IfSupported'],
'PLAIN' => 1, // $encrypted 'PLAIN' => 1, // $encrypted
'LOGIN' => 1 // $encrypted 'LOGIN' => 1 // $encrypted
]; ];
@ -131,17 +133,17 @@ class ManageSieveClient extends \MailSo\Net\NetClient
$bAuth = false; $bAuth = false;
try try
{ {
if ('PLAIN' === $type) if ('PLAIN' === $type || 'OAUTHBEARER' === $type || 'XOAUTH2' === $type)
{ {
$sAuth = $SASL->authenticate($sLogin, $sPassword, $sLoginAuthKey); $sAuth = $SASL->authenticate($sLogin, $sPassword, $sLoginAuthKey);
if ($aCredentials['InitialAuthPlain']) if ($aCredentials['InitialAuthPlain'])
{ {
$this->sendRequest('AUTHENTICATE "PLAIN" "'.$sAuth.'"'); $this->sendRequest("AUTHENTICATE \"{$type}\" \"{$sAuth}\"");
} }
else else
{ {
$this->sendRequest('AUTHENTICATE "PLAIN" {'.\strlen($sAuth).'+}'); $this->sendRequest("AUTHENTICATE \"{$type}\" {".\strlen($sAuth).'+}');
$this->sendRequest($sAuth); $this->sendRequest($sAuth);
} }