Skip to content

Commit

Permalink
Fix OAuth for Kinde && support smtp w/o authentication (#9244, #9183)
Browse files Browse the repository at this point in the history
Co-authored-by: kc <kc@white.colors.lan>
  • Loading branch information
libc225so and kc committed Dec 23, 2023
1 parent 740267f commit 504cdb8
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion program/include/rcmail_oauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,14 @@ protected function parse_tokens($grant_type, &$data, $previous_data = null)

$data['refresh_expires'] = time() + $data['refresh_expires_in'];

$authorization = sprintf('%s %s', $data['token_type'], $data['access_token']);
if (strcasecmp($data['token_type'], 'Bearer') == 0) {
// always normalize Bearer (uppercase then lower case)
$authorization = sprintf('Bearer %s', $data['access_token']);
}
else {
// unknown token type, do not alter it
$authorization = sprintf('%s %s', $data['token_type'], $data['access_token']);
}

return $authorization;
}
Expand Down Expand Up @@ -964,6 +971,14 @@ public function storage_init($options)
*/
public function smtp_connect($options)
{
$smtp_user = $options['smtp_user'];
$smtp_pass = $options['smtp_pass'];

// skip XOAUTH2 authorization, if indicated
if (($smtp_user == '') || ($smtp_pass == '')) {
return $options;
}

if (isset($_SESSION['oauth_token'])) {
// check token validity
$this->check_token_validity($_SESSION['oauth_token']);
Expand Down

0 comments on commit 504cdb8

Please sign in to comment.