Test Authentification
This commit is contained in:
parent
78e6e5787c
commit
de1f302047
3 changed files with 55 additions and 35 deletions
69
server/core/LibOverride/Test.php
Normal file → Executable file
69
server/core/LibOverride/Test.php
Normal file → Executable file
|
@ -1,24 +1,56 @@
|
|||
<?php
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use OpenStack\Common\Transport\HandlerStack;
|
||||
use OpenStack\Common\Transport\Middleware;
|
||||
use OpenStack\Identity\v3\Service;
|
||||
use OpenStack\Common\Auth\Token;
|
||||
use OpenStack\Common\Transport\Utils;
|
||||
|
||||
class genTokenOptions
|
||||
{
|
||||
private $clientHTTP;
|
||||
private $optionsGlobal;
|
||||
|
||||
public function __construct(){
|
||||
public function __construct($options, $token){
|
||||
echo "test";
|
||||
|
||||
$stack = HandlerStack::create();
|
||||
//IdentityService?
|
||||
// $options['IdentityService'] pas oblige?...
|
||||
// creer HttpClient authurl HandlerStack::create()
|
||||
// $option['identityService'] = factory httpClient
|
||||
//$httpClient = new Client([
|
||||
// 'base_uri' => Utils::normalizeUrl($options['authUrl']),
|
||||
// 'handler' => HandlerStack::create(),
|
||||
//]);
|
||||
|
||||
$httpClient = new Client([
|
||||
'base_uri' => Utils::normalizeUrl($options['authUrl']),
|
||||
'handler' => $stack,
|
||||
]);
|
||||
|
||||
$options['identityService'] = Service::factory($httpClient);
|
||||
//AuthHadler?
|
||||
//
|
||||
$options['authHandler'] = function () use ($options) {
|
||||
return $options['identityService']->generateToken($options);
|
||||
};
|
||||
//StockClient?
|
||||
// creer $options['httpClient'] instance de ClientInterface
|
||||
// token, baseUrl = identity->authenticate
|
||||
// stack = getStack authhandler token
|
||||
// addDebug??
|
||||
// $options['httpClient'] = httpCLient baseurl stack
|
||||
|
||||
$baseUrl = $options['authUrl'];
|
||||
|
||||
//$stack = HandlerStack::create();
|
||||
$stack->push(Middleware::authHandler($options['authHandler'], $token));
|
||||
|
||||
$this->addDebugMiddleware($options, $stack);
|
||||
|
||||
$options['httpClient'] = $httpClient;
|
||||
|
||||
$this->optionsGlobal = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,31 +65,8 @@ class genTokenOptions
|
|||
$stack->push(GuzzleMiddleware::log($options['logger'], $options['messageFormatter']));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param array $options
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
private function stockAuthHandler(array &$options)
|
||||
{
|
||||
if (!isset($options['authHandler'])) {
|
||||
$options['authHandler'] = function () use ($options) {
|
||||
return $options['identityService']->generateToken($options);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private function getStack(callable $authHandler, Token $token = null)
|
||||
{
|
||||
$stack = HandlerStack::create();
|
||||
$stack->push(Middleware::authHandler($authHandler, $token));
|
||||
return $stack;
|
||||
}
|
||||
|
||||
private function httpClient($baseUrl, HandlerStack $stack)
|
||||
{
|
||||
return new Client([
|
||||
'base_uri' => Utils::normalizeUrl($baseUrl),
|
||||
'handler' => $stack,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getOptions(){
|
||||
return $this->optionsGlobal;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue