dvadf
File manager - Edit - /home/centroca/public_html/AuthHandler.tar
Back
Guzzle7AuthHandler.php 0000644 00000001346 15253106537 0010757 0 ustar 00 <?php /** * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ namespace WPMailSMTP\Vendor\Google\AuthHandler; /** * This supports Guzzle 7 */ class Guzzle7AuthHandler extends Guzzle6AuthHandler { } Guzzle6AuthHandler.php 0000644 00000006112 15253106537 0010752 0 ustar 00 <?php namespace WPMailSMTP\Vendor\Google\AuthHandler; use WPMailSMTP\Vendor\Google\Auth\CredentialsLoader; use WPMailSMTP\Vendor\Google\Auth\FetchAuthTokenCache; use WPMailSMTP\Vendor\Google\Auth\HttpHandler\HttpHandlerFactory; use WPMailSMTP\Vendor\Google\Auth\Middleware\AuthTokenMiddleware; use WPMailSMTP\Vendor\Google\Auth\Middleware\ScopedAccessTokenMiddleware; use WPMailSMTP\Vendor\Google\Auth\Middleware\SimpleMiddleware; use WPMailSMTP\Vendor\GuzzleHttp\Client; use WPMailSMTP\Vendor\GuzzleHttp\ClientInterface; use WPMailSMTP\Vendor\Psr\Cache\CacheItemPoolInterface; /** * This supports Guzzle 6 */ class Guzzle6AuthHandler { protected $cache; protected $cacheConfig; public function __construct(?CacheItemPoolInterface $cache = null, array $cacheConfig = []) { $this->cache = $cache; $this->cacheConfig = $cacheConfig; } public function attachCredentials(ClientInterface $http, CredentialsLoader $credentials, ?callable $tokenCallback = null) { // use the provided cache if ($this->cache) { $credentials = new FetchAuthTokenCache($credentials, $this->cacheConfig, $this->cache); } return $this->attachCredentialsCache($http, $credentials, $tokenCallback); } public function attachCredentialsCache(ClientInterface $http, FetchAuthTokenCache $credentials, ?callable $tokenCallback = null) { // if we end up needing to make an HTTP request to retrieve credentials, we // can use our existing one, but we need to throw exceptions so the error // bubbles up. $authHttp = $this->createAuthHttp($http); $authHttpHandler = HttpHandlerFactory::build($authHttp); $middleware = new AuthTokenMiddleware($credentials, $authHttpHandler, $tokenCallback); $config = $http->getConfig(); $config['handler']->remove('google_auth'); $config['handler']->push($middleware, 'google_auth'); $config['auth'] = 'google_auth'; $http = new Client($config); return $http; } public function attachToken(ClientInterface $http, array $token, array $scopes) { $tokenFunc = function ($scopes) use($token) { return $token['access_token']; }; $middleware = new ScopedAccessTokenMiddleware($tokenFunc, $scopes, $this->cacheConfig, $this->cache); $config = $http->getConfig(); $config['handler']->remove('google_auth'); $config['handler']->push($middleware, 'google_auth'); $config['auth'] = 'scoped'; $http = new Client($config); return $http; } public function attachKey(ClientInterface $http, $key) { $middleware = new SimpleMiddleware(['key' => $key]); $config = $http->getConfig(); $config['handler']->remove('google_auth'); $config['handler']->push($middleware, 'google_auth'); $config['auth'] = 'simple'; $http = new Client($config); return $http; } private function createAuthHttp(ClientInterface $http) { return new Client(['http_errors' => \true] + $http->getConfig()); } } AuthHandlerFactory.php 0000644 00000003243 15253106537 0011015 0 ustar 00 <?php /** * Copyright 2015 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ namespace WPMailSMTP\Vendor\Google\AuthHandler; use Exception; use WPMailSMTP\Vendor\GuzzleHttp\ClientInterface; class AuthHandlerFactory { /** * Builds out a default http handler for the installed version of guzzle. * * @return Guzzle6AuthHandler|Guzzle7AuthHandler * @throws Exception */ public static function build($cache = null, array $cacheConfig = []) { $guzzleVersion = null; if (\defined('\\WPMailSMTP\\Vendor\\GuzzleHttp\\ClientInterface::MAJOR_VERSION')) { $guzzleVersion = ClientInterface::MAJOR_VERSION; } elseif (\defined('\\WPMailSMTP\\Vendor\\GuzzleHttp\\ClientInterface::VERSION')) { $guzzleVersion = (int) \substr(ClientInterface::VERSION, 0, 1); } switch ($guzzleVersion) { case 6: return new Guzzle6AuthHandler($cache, $cacheConfig); case 7: return new Guzzle7AuthHandler($cache, $cacheConfig); default: throw new Exception('Version not supported'); } } }
dvadf
dvadf
| ver. 1.4 |
Github
|
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings