Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oauth: add a generic method OAUTH to choose automatically a supported method #11

Merged
merged 1 commit into from
Dec 29, 2023
Merged
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
15 changes: 14 additions & 1 deletion Sieve.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ class Net_Sieve
* @param string $host Hostname of server.
* @param string $port Port of server.
* @param string $logintype Type of login to perform (see
* $supportedAuthMethods).
* $supportedAuthMethods), use `OAUTH` and lib
* will choose between OAUTHBEARER or XOAUTH2
* according the server's capabilities.
* @param string $euser Effective user. If authenticating as an
* administrator, login as this user.
* @param boolean $debug Whether to enable debugging (@see setDebug()).
Expand Down Expand Up @@ -458,6 +460,17 @@ function login($user, $pass, $logintype = null, $euser = '', $bypassAuth = false
}

if (!$bypassAuth ) {
// special case of OAUTH, use the supported method
if ($logintype === 'OAUTH') {
$supported_logintypes = $this->_capability['sasl'];
foreach (['OAUTHBEARER', 'XOAUTH2'] as $logintype) {
if (in_array($logintype, $supported_logintypes)) {
break;
}
}
$this->_data['logintype'] = $logintype;
}

$res = $this->_cmdAuthenticate($user, $pass, $logintype, $euser);
if (is_a($res, 'PEAR_Error')) {
return $res;
Expand Down