Skip to content

Commit

Permalink
OAuth: Fix some PHP warnings and improve debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
alecpl committed Aug 27, 2024
1 parent ae23dad commit 4023931
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions program/include/rcmail_oauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,7 @@ protected function discover(): void

// map discovery to our options
foreach (self::$config_mapper as $config_key => $options_key) {
if (empty($data[$config_key])) {
rcube::raise_error("Key {$config_key} not found in answer of {$config_uri}", true);
} else {
if (!empty($data[$config_key])) {
$this->options[$options_key] = $data[$config_key];
}
}
Expand Down Expand Up @@ -520,7 +518,7 @@ public function login_redirect(): void
}

/**
* Call ODIC to get identity for an given authorization
* Call OIDC to get identity for a given authorization
*
* @param string $authorization the Bearer authorization
*
Expand Down Expand Up @@ -793,16 +791,7 @@ protected function is_token_revoked($token)
*/
protected function parse_tokens($grant_type, &$data, $previous_data = null)
{
// TODO move it into to log_info ?
$this->log_debug('received tokens from a grant request %s: session: %s with scope %s, '
. 'access_token type %s exp in %ss, refresh_token exp in %ss, id_token present: %s, not-before-policy: %s',
$grant_type,
$data['session_state'], $data['scope'],
$data['token_type'], $data['expires_in'],
$data['refresh_expires_in'],
isset($data['id_token']),
$data['not-before-policy'] ?? null
);
$this->log_debug('received tokens from a grant request %s: %s', $grant_type, json_encode($data));

if (is_array($previous_data)) {
$this->log_debug(
Expand Down Expand Up @@ -856,7 +845,9 @@ protected function parse_tokens($grant_type, &$data, $previous_data = null)
$data['expires'] = time() + $data['expires_in'] - $refresh_interval - 10;
}

$data['refresh_expires'] = time() + $data['refresh_expires_in'];
if (isset($data['refresh_expires_in'])) {
$data['refresh_expires'] = time() + $data['refresh_expires_in'];
}

if (strcasecmp($data['token_type'], 'Bearer') == 0) {
// always normalize Bearer (uppercase then lower case)
Expand Down

0 comments on commit 4023931

Please sign in to comment.