Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/roundcube/roundcubemail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJorge López Pérez <jorge@jorgelp.com>2022-08-09 20:13:58 +0300
committerGitHub <noreply@github.com>2022-08-09 20:13:58 +0300
commite808fba4f89702a5f07abdb452bdcb802541b93e (patch)
tree8978b65eed135f9236b2033a8da412bde07e3e9c
parent864e0710a355f3850e61583a2134e28e935aa59a (diff)
Initialize HTTP client using get_http_client() for OAuth requests (#8666)
* Initialize HTTP client using get_http_client() for OAuth requests * Add new oauth_timeout setting
-rw-r--r--config/defaults.inc.php3
-rw-r--r--program/include/rcmail_oauth.php10
2 files changed, 8 insertions, 5 deletions
diff --git a/config/defaults.inc.php b/config/defaults.inc.php
index 3794e99da..afdeda6f3 100644
--- a/config/defaults.inc.php
+++ b/config/defaults.inc.php
@@ -358,6 +358,9 @@ $config['oauth_token_uri'] = null;
// Optional: Endpoint to query user identity if not provided in auth response
$config['oauth_identity_uri'] = null;
+// Optional: timeout for HTTP requests to OAuth server
+$config['oauth_timeout'] = 10;
+
// Optional: disable SSL certificate check on HTTP requests to OAuth server
// See http://docs.guzzlephp.org/en/stable/request-options.html#verify for possible values
$config['oauth_verify_peer'] = true;
diff --git a/program/include/rcmail_oauth.php b/program/include/rcmail_oauth.php
index 7d0fca84b..b2f954c7e 100644
--- a/program/include/rcmail_oauth.php
+++ b/program/include/rcmail_oauth.php
@@ -17,7 +17,6 @@
+-----------------------------------------------------------------------+
*/
-use GuzzleHttp\Client;
use GuzzleHttp\MessageFormatter;
use GuzzleHttp\Exception\RequestException;
@@ -76,6 +75,7 @@ class rcmail_oauth
'identity_uri' => $this->rcmail->config->get('oauth_identity_uri'),
'identity_fields' => $this->rcmail->config->get('oauth_identity_fields', ['email']),
'scope' => $this->rcmail->config->get('oauth_scope'),
+ 'timeout' => $this->rcmail->config->get('oauth_timeout', 10),
'verify_peer' => $this->rcmail->config->get('oauth_verify_peer', true),
'auth_parameters' => $this->rcmail->config->get('oauth_auth_parameters', []),
'login_redirect' => $this->rcmail->config->get('oauth_login_redirect', false),
@@ -219,8 +219,8 @@ class rcmail_oauth
}
// send token request to get a real access token for the given auth code
- $client = new Client([
- 'timeout' => 10.0,
+ $client = rcube::get_instance()->get_http_client([
+ 'timeout' => $this->options['timeout'],
'verify' => $this->options['verify_peer'],
]);
@@ -366,8 +366,8 @@ class rcmail_oauth
// send token request to get a real access token for the given auth code
try {
- $client = new Client([
- 'timeout' => 10.0,
+ $client = rcube::get_instance()->get_http_client([
+ 'timeout' => $this->options['timeout'],
'verify' => $this->options['verify_peer'],
]);
$response = $client->post($oauth_token_uri, [