From 78e6e5787ce2df4ae55f5b4d64c792b8f20696d7 Mon Sep 17 00:00:00 2001 From: Eole Date: Sat, 30 Jan 2016 11:41:45 +0100 Subject: Begin of Identity Implementation, Begin of Token management for Identification --- server/index.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'server/index.php') diff --git a/server/index.php b/server/index.php index ca84641..ceba59e 100644 --- a/server/index.php +++ b/server/index.php @@ -3,7 +3,14 @@ include_once("config.inc.php"); include_once("init.php"); - $task = $_POST["task"]; - $action = $_POST["action"]; - +// $task = $_POST["task"]; +// $action = $_POST["action"]; + include_once("core/Identity.php"); + + //$id = new identity($openstack_api, $pluginApi); + +// var_dump($id->genToken()); + $openstack_api->computeV2(['region'=> 'RegionOne']); + +// var_dump($openstack_api->getBuilderOptions()); -- cgit v1.2.3 From de1f3020478a471e0041c1030231bb5462640fd8 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 31 Jan 2016 02:38:05 +0100 Subject: Test Authentification --- server/core/LibOverride/Test.php | 69 +++++++++++++++++++++++----------------- server/index.php | 7 ++-- server/init.php | 12 ++++++- 3 files changed, 54 insertions(+), 34 deletions(-) mode change 100644 => 100755 server/core/LibOverride/Test.php mode change 100644 => 100755 server/index.php mode change 100644 => 100755 server/init.php (limited to 'server/index.php') diff --git a/server/core/LibOverride/Test.php b/server/core/LibOverride/Test.php old mode 100644 new mode 100755 index a1c8023..09f08d5 --- a/server/core/LibOverride/Test.php +++ b/server/core/LibOverride/Test.php @@ -1,24 +1,56 @@ 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; + } } diff --git a/server/index.php b/server/index.php old mode 100644 new mode 100755 index ceba59e..5259a69 --- a/server/index.php +++ b/server/index.php @@ -5,12 +5,13 @@ // $task = $_POST["task"]; // $action = $_POST["action"]; - - include_once("core/Identity.php"); + //$id = new identity($openstack_api, $pluginApi); // var_dump($id->genToken()); - $openstack_api->computeV2(['region'=> 'RegionOne']); + $compute = $openstack_api->computeV2(['region'=> 'RegionOne']); + $servers = $compute->listServers(true); + var_dump($servers); // var_dump($openstack_api->getBuilderOptions()); diff --git a/server/init.php b/server/init.php old mode 100644 new mode 100755 index 5b6a6c1..e186667 --- a/server/init.php +++ b/server/init.php @@ -4,6 +4,8 @@ require "vendor/autoload.php"; include_once("core/LibOverride/Builder.php"); include_once("core/LibOverride/OpenStack.php"); + include_once("core/LibOverride/Test.php"); + include_once("core/Identity.php"); //traitement requete, recuperation data if(isset($_POST["key"])){ @@ -54,7 +56,15 @@ ); } + $pluginApi = plugin_api::getInstance(); + $openstack_api = new OpenStack\OpenStack($Args); + $id = new identity($openstack_api, $pluginApi); + + $token = $id->genToken(); + + $tmp = new genTokenOptions($Args, $token); + $array = $tmp->getOptions(); + $openstack_api = new OpenStack\OpenStack($array); - $pluginApi = plugin_api::getInstance(); ?> -- cgit v1.2.3 From 7276d3f0334785a33ab23ef80db1e2ea77d24922 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 31 Jan 2016 03:24:02 +0100 Subject: Suite Test Token Management --- server/core/LibOverride/Test.php | 60 ++++++++++++++++++++-------------------- server/index.php | 2 +- server/init.php | 13 +++++---- 3 files changed, 38 insertions(+), 37 deletions(-) (limited to 'server/index.php') diff --git a/server/core/LibOverride/Test.php b/server/core/LibOverride/Test.php index 09f08d5..4e8e540 100755 --- a/server/core/LibOverride/Test.php +++ b/server/core/LibOverride/Test.php @@ -10,47 +10,26 @@ use OpenStack\Common\Transport\Utils; class genTokenOptions { private $optionsGlobal; + + private $stack; - public function __construct($options, $token){ + public function __construct($options){ 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(), - //]); + $this->stack = HandlerStack::create(); - $httpClient = new Client([ + $httpClient['Common'] = 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; + $this->optionsGlobal['Common'] = $options; } /** @@ -66,7 +45,28 @@ class genTokenOptions } } - public function getOptions(){ - return $this->optionsGlobal; + public genComputeToken(){ + $options = $this->optionsGlobal['Common']; + $options['catalogName'] = 'nova'; + $options['catalogType'] = 'compute'; + $options['region'] = 'RegionOne'; + + list($token, $baseUrl) = $options['identityService']->authenticate($options); + + //$stack = HandlerStack::create(); + $this->stack->push(Middleware::authHandler($options['authHandler'], $token)); + + $this->addDebugMiddleware($options, $this->stack); + + $options['httpClient'] = new Client([ + 'base_uri' => Utils::normalizeUrl($options['authUrl']), + 'handler' => $stack, + ]); + + $this->optionsGlobal['Compute'] = $options; + } + + public function getOptionsCompute(){ + return $this->optionsGlobal['Compute']; } } diff --git a/server/index.php b/server/index.php index 5259a69..23c99a1 100755 --- a/server/index.php +++ b/server/index.php @@ -10,7 +10,7 @@ //$id = new identity($openstack_api, $pluginApi); // var_dump($id->genToken()); - $compute = $openstack_api->computeV2(['region'=> 'RegionOne']); + $compute = $openstack_api->computeV2($array); $servers = $compute->listServers(true); var_dump($servers); diff --git a/server/init.php b/server/init.php index e186667..a7989ce 100755 --- a/server/init.php +++ b/server/init.php @@ -58,13 +58,14 @@ $pluginApi = plugin_api::getInstance(); - $openstack_api = new OpenStack\OpenStack($Args); - $id = new identity($openstack_api, $pluginApi); + //$openstack_api = new OpenStack\OpenStack($Args); + //$id = new identity($openstack_api, $pluginApi); - $token = $id->genToken(); + //$token = $id->genToken(); - $tmp = new genTokenOptions($Args, $token); - $array = $tmp->getOptions(); - $openstack_api = new OpenStack\OpenStack($array); + $tmp = new genTokenOptions($Args); + $tmp->genComputeToken(); + $array = $tmp->getOptionsCompute(); + $openstack_api = new OpenStack\OpenStack(new array()); ?> -- cgit v1.2.3 From 6c4cdf62ac99a56cefb663ad4779dd07f0944a26 Mon Sep 17 00:00:00 2001 From: Eole Date: Sun, 31 Jan 2016 04:00:20 +0100 Subject: Test Serialization Token Debut --- server/core/LibOverride/Test.php | 43 ++++++++++++++++++++++++++++++++++------ server/index.php | 13 ++++++++++++ server/init.php | 7 +++++-- 3 files changed, 55 insertions(+), 8 deletions(-) (limited to 'server/index.php') diff --git a/server/core/LibOverride/Test.php b/server/core/LibOverride/Test.php index 4e8e540..5babc35 100755 --- a/server/core/LibOverride/Test.php +++ b/server/core/LibOverride/Test.php @@ -12,15 +12,16 @@ class genTokenOptions private $optionsGlobal; private $stack; + private $backup = []; public function __construct($options){ echo "test"; $this->stack = HandlerStack::create(); - $httpClient['Common'] = new Client([ + $httpClient = new Client([ 'base_uri' => Utils::normalizeUrl($options['authUrl']), - 'handler' => $stack, + 'handler' => $this->stack, ]); $options['identityService'] = Service::factory($httpClient); @@ -45,26 +46,56 @@ class genTokenOptions } } - public genComputeToken(){ + public function genComputeToken(){ $options = $this->optionsGlobal['Common']; $options['catalogName'] = 'nova'; $options['catalogType'] = 'compute'; $options['region'] = 'RegionOne'; list($token, $baseUrl) = $options['identityService']->authenticate($options); - + var_dump($token); //$stack = HandlerStack::create(); $this->stack->push(Middleware::authHandler($options['authHandler'], $token)); $this->addDebugMiddleware($options, $this->stack); $options['httpClient'] = new Client([ - 'base_uri' => Utils::normalizeUrl($options['authUrl']), - 'handler' => $stack, + 'base_uri' => Utils::normalizeUrl($baseUrl), + 'handler' => $this->stack, ]); + $this->backup['Compute'] = array('token' => serialize($token), 'baseUrl' => $baseUrl ); + $this->optionsGlobal['Compute'] = $options; + } + + public function loadComputeBackup($opt){ + + $options = $this->optionsGlobal['Common']; + $options['catalogName'] = 'nova'; + $options['catalogType'] = 'compute'; + $options['region'] = 'RegionOne'; + //list($token, $baseUrl) = $options['identityService']->authenticate($options); + $this->backup['Compute'] = unserialize($opt); + $token = unserialize($this->backup['Compute'] ['token']); + $baseUrl = $this->backup['Compute']['baseUrl']; + + //$stack = HandlerStack::create(); + + $this->stack->push(Middleware::authHandler($options['authHandler'], $token)); + + $this->addDebugMiddleware($options, $this->stack); + + $options['httpClient'] = new Client([ + 'base_uri' => Utils::normalizeUrl($baseUrl), + 'handler' => $this->stack, + ]); + $this->backup['Compute'] = array('token' => serialize($token), 'baseUrl' => $baseUrl ); $this->optionsGlobal['Compute'] = $options; } + + public function getBackup($service){ + return serialize($this->backup[$service]); + } public function getOptionsCompute(){ return $this->optionsGlobal['Compute']; diff --git a/server/index.php b/server/index.php index 23c99a1..b5424da 100755 --- a/server/index.php +++ b/server/index.php @@ -13,5 +13,18 @@ $compute = $openstack_api->computeV2($array); $servers = $compute->listServers(true); var_dump($servers); + foreach($servers as $server){ + echo $server->id." !!!!!!!!! "; + } + $tmp = new genTokenOptions($Args); + $tmp->loadComputeBackup($computBack); + $array = $tmp->getOptionsCompute(); + + $openstackTest = new OpenStack\OpenStack([]); + $computeTest = $openstackTest->computeV2($array); + $serversTest = $computeTest->listServers(true); + foreach($serversTest as $server){ + echo $server->id." %%%%%% "; + } // var_dump($openstack_api->getBuilderOptions()); diff --git a/server/init.php b/server/init.php index a7989ce..3c5f848 100755 --- a/server/init.php +++ b/server/init.php @@ -66,6 +66,9 @@ $tmp = new genTokenOptions($Args); $tmp->genComputeToken(); $array = $tmp->getOptionsCompute(); - $openstack_api = new OpenStack\OpenStack(new array()); - + $openstack_api = new OpenStack\OpenStack([]); + + $computBack = $tmp->getBackup("Compute"); + //file_put_contents("token", serialize($tmp)); + ?> -- cgit v1.2.3 From f6c4c90567161fdb73e0fcec5f3d330c3a118a60 Mon Sep 17 00:00:00 2001 From: Eole Date: Sun, 31 Jan 2016 11:54:53 +0100 Subject: Fin test Token Management --- server/core/LibOverride/Test.php | 172 ++++++++++++++++++++++++++++----------- server/index.php | 6 +- 2 files changed, 126 insertions(+), 52 deletions(-) (limited to 'server/index.php') diff --git a/server/core/LibOverride/Test.php b/server/core/LibOverride/Test.php index beb4e70..91ea84d 100755 --- a/server/core/LibOverride/Test.php +++ b/server/core/LibOverride/Test.php @@ -4,8 +4,10 @@ use GuzzleHttp\Client; use OpenStack\Common\Transport\HandlerStack; use OpenStack\Common\Transport\Middleware; use OpenStack\Identity\v3\Service; +use OpenStack\Identity\v3\Api; use OpenStack\Common\Auth\Token; use OpenStack\Common\Transport\Utils; +use OpenStack\Identity\v3\Models; class genTokenOptions { @@ -13,9 +15,9 @@ class genTokenOptions private $stack; private $backup = []; + private $httpClient; public function __construct($options){ - echo "test"; $this->stack = HandlerStack::create(); @@ -24,6 +26,8 @@ class genTokenOptions 'handler' => $this->stack, ]); + $this->httpClient = $httpClient; + $options['identityService'] = Service::factory($httpClient); $options['authHandler'] = function () use ($options) { @@ -63,49 +67,8 @@ class genTokenOptions 'base_uri' => Utils::normalizeUrl($baseUrl), 'handler' => $this->stack, ]); - $this->backup['Compute'] = array('token' => json_encode($token), 'baseUrl' => $baseUrl ); - serialize($token->methods); - foreach($token->roles as $role){ - serialize($role->name); - serialize($role->links); - serialize($role->id); - } - serialize($token->expires); - serialize($token->project->domainId); - serialize($token->project->parentId); - serialize($token->project->enabled); - serialize($token->project->description); - serialize($token->project->id); - serialize($token->project->links); - serialize($token->project->name); - foreach($token->catalog->services as $service){ - serialize($service->id); - serialize($service->name); - serialize($service->description); - serialize($service->type); - foreach($service->endpoints as $end){ - serialize($end->id); - serialize($end->interface); - serialize($end->name); - serialize($end->serviceId); - serialize($end->region); - serialize($end->links); - serialize($end->url); - } - serialize($service->links); - } - serialize($token->extras); - serialize($token->user->domainId); - serialize($token->user->defaultProjectId); - serialize($token->user->id); - serialize($token->user->email); - serialize($token->user->enabled); - serialize($token->user->description); - serialize($token->user->links); - serialize($token->user->name); - serialize($token->issued); - serialize($token->id); - var_dump($token->id); + $this->backup['Compute'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl ); + $this->optionsGlobal['Compute'] = $options; } @@ -117,9 +80,9 @@ class genTokenOptions $options['region'] = 'RegionOne'; //list($token, $baseUrl) = $options['identityService']->authenticate($options); - $this->backup['Compute'] = json_decode($opt, true); - var_dump($this->backup['Compute']); - $token = json_decode($this->backup['Compute']['token'], true); + $this->backup['Compute'] = unserialize($opt); + //var_dump($this->backup['Compute']); + $token = $this->unserializeToken($this->backup['Compute']['token']); $baseUrl = $this->backup['Compute']['baseUrl']; //$stack = HandlerStack::create(); @@ -132,15 +95,126 @@ class genTokenOptions 'base_uri' => Utils::normalizeUrl($baseUrl), 'handler' => $this->stack, ]); - $this->backup['Compute'] = array('token' => json_encode($token), 'baseUrl' => $baseUrl ); + $this->backup['Compute'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl ); $this->optionsGlobal['Compute'] = $options; } public function getBackup($service){ - return json_encode($this->backup[$service]); + return serialize($this->backup[$service]); } public function getOptionsCompute(){ return $this->optionsGlobal['Compute']; } + + private function serializeToken($token){ + $tokenSerialized = []; + $tokenSerialized["methods"] = serialize($token->methods); + $tokenSerialized["roles"] = []; + //var_dump($token->roles); + foreach($token->roles as $role){ + $tokenSerialized["roles"][serialize($role->name)]["links"] = serialize($role->links); + $tokenSerialized["roles"][serialize($role->name)]["id"] = serialize($role->id); + } + $tokenSerialized["expires"] = serialize($token->expires); + $tokenSerialized["project"]["domainId"] = serialize($token->project->domainId); + $tokenSerialized["project"]["parentId"] = serialize($token->project->parentId); + $tokenSerialized["project"]["enabled"] = serialize($token->project->enabled); + $tokenSerialized["project"]["description"] = serialize($token->project->description); + $tokenSerialized["project"]["id"] = serialize($token->project->id); + $tokenSerialized["project"]["links"] = serialize($token->project->links); + $tokenSerialized["project"]["name"] = serialize($token->project->name); + foreach($token->catalog->services as $service){ + $tokenSerialized["catalog"][serialize($service->id)]["name"] = serialize($service->name); + $tokenSerialized["catalog"][serialize($service->id)]["description"] = serialize($service->description); + $tokenSerialized["catalog"][serialize($service->id)]["type"] = serialize($service->type); + foreach($service->endpoints as $end){ + $tokenSerialized["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["interface"] = serialize($end->interface); + $tokenSerialized["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["name"] = serialize($end->name); + $tokenSerialized["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["serviceId"] = serialize($end->serviceId); + $tokenSerialized["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["region"] = serialize($end->region); + $tokenSerialized["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["links"] = serialize($end->links); + $tokenSerialized["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["url"] = serialize($end->url); + } + $tokenSerialized["roles"][serialize($service->id)]["links"] = serialize($service->links); + } + $tokenSerialized["extras"] = serialize($token->extras); + $tokenSerialized["user"]["domainId"] = serialize($token->user->domainId); + $tokenSerialized["user"]["defaultProjectId"] = serialize($token->user->defaultProjectId); + $tokenSerialized["user"]["id"] = serialize($token->user->id); + $tokenSerialized["user"]["email"] = serialize($token->user->email); + $tokenSerialized["user"]["enabled"] = serialize($token->user->enabled); + $tokenSerialized["user"]["description"] = serialize($token->user->description); + $tokenSerialized["user"]["links"] = serialize($token->user->links); + $tokenSerialized["user"]["name"] = serialize($token->user->name); + $tokenSerialized["issued"] = serialize($token->issued); + $tokenSerialized["id"] = serialize($token->id); + + return $tokenSerialized; + } + + private function unserializeToken($tokenSerialized){ + $api = new Api(); + $token = new Models\Token($this->httpClient, $api); + $token->methods = unserialize($tokenSerialized["methods"]); + $token->roles = []; + foreach($tokenSerialized["roles"] as $key => $role){ + $tmp = new Models\Role($this->httpClient, $api); + + $tmp->name = unserialize($key); + $tmp->links = unserialize($role["links"]); + $tmp->id = unserialize($role["id"]); + + $token->roles[] = $tmp; + } + + $token->expires = unserialize($tokenSerialized["expires"]); + $token->project = new Models\Project($this->httpClient, $api); + $token->project->domainId = unserialize($tokenSerialized["project"]["domainId"]); + $token->project->parentId = unserialize($tokenSerialized["project"]["parentId"]); + $token->project->enabled = unserialize($tokenSerialized["project"]["enabled"]); + $token->project->description = unserialize($tokenSerialized["project"]["description"]); + $token->project->id = unserialize($tokenSerialized["project"]["id"]); + $token->project->links = unserialize($tokenSerialized["project"]["links"]); + $token->project->name = unserialize($tokenSerialized["project"]["name"]); + + $token->catalog = []; + foreach($tokenSerialized["catalog"] as $key => $service){ + $tmp = new Models\Service($this->httpClient, $api); + + $tmp->id = unserialize($key); + $tmp->name = unserialize($service["name"]); + $tmp->description = unserialize($service["description"]); + $tmp->type = unserialize($service["type"]); + $tmp->endpoints = []; + foreach($service["endpoints"] as $key => $end){ + $tmpEnd = new Models\Endpoint($this->httpClient, $api); + $tmpEnd->id = unserialize($key); + $tmpEnd->interface = unserialize($end["interface"]); + $tmpEnd->name = unserialize($end["name"]); + $tmpEnd->serviceId = unserialize($end["serviceId"]); + $tmpEnd->region = unserialize($end["region"]); + $tmpEnd->links = unserialize($end["links"]); + $tmpEnd->url = unserialize($end["url"]); + $tmp->endpoints[] = $tmpEnd; + } + $tmp->links = unserialize($service["links"]); + $token->catalog[] = $tmp; + } + + $token->extras = unserialize($tokenSerialized["extras"]); + $token->user = new Models\User($this->httpClient, $api); + $token->user->domainId = unserialize($tokenSerialized["user"]["domainId"]); + $token->user->defaultProjectId = unserialize($tokenSerialized["user"]["defaultProjectId"]); + $token->user->id = unserialize($tokenSerialized["user"]["id"]); + $token->user->email = unserialize($tokenSerialized["user"]["email"]); + $token->user->enabled = unserialize($tokenSerialized["user"]["enabled"]); + $token->user->links = unserialize($tokenSerialized["user"]["links"]); + $token->user->name = unserialize($tokenSerialized["user"]["name"]); + $token->user->description = unserialize($tokenSerialized["user"]["description"]); + $token->issued = unserialize($tokenSerialized["issued"]); + $token->id = unserialize($tokenSerialized["id"]); + + return $token; + } } diff --git a/server/index.php b/server/index.php index b5424da..c99e8bc 100755 --- a/server/index.php +++ b/server/index.php @@ -12,9 +12,9 @@ // var_dump($id->genToken()); $compute = $openstack_api->computeV2($array); $servers = $compute->listServers(true); - var_dump($servers); + //var_dump($servers); foreach($servers as $server){ - echo $server->id." !!!!!!!!! "; + // echo $server->id." !!!!!!!!! "; } $tmp = new genTokenOptions($Args); @@ -25,6 +25,6 @@ $computeTest = $openstackTest->computeV2($array); $serversTest = $computeTest->listServers(true); foreach($serversTest as $server){ - echo $server->id." %%%%%% "; + // echo $server->id." %%%%%% "; } // var_dump($openstack_api->getBuilderOptions()); -- cgit v1.2.3 From 4c0fb055903b7cc1eaf8d6c65237e362edf4b18d Mon Sep 17 00:00:00 2001 From: Eole Date: Sun, 31 Jan 2016 12:16:31 +0100 Subject: Fin Token --- server/core/LibOverride/Test.php | 25 ++++++++++++++++--------- server/index.php | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) (limited to 'server/index.php') diff --git a/server/core/LibOverride/Test.php b/server/core/LibOverride/Test.php index 91ea84d..10a7837 100755 --- a/server/core/LibOverride/Test.php +++ b/server/core/LibOverride/Test.php @@ -111,11 +111,12 @@ class genTokenOptions $tokenSerialized = []; $tokenSerialized["methods"] = serialize($token->methods); $tokenSerialized["roles"] = []; - //var_dump($token->roles); + foreach($token->roles as $role){ - $tokenSerialized["roles"][serialize($role->name)]["links"] = serialize($role->links); - $tokenSerialized["roles"][serialize($role->name)]["id"] = serialize($role->id); - } + $tokenSerialized["roles"][serialize($role->id)]["links"] = serialize($role->links); + $tokenSerialized["roles"][serialize($role->id)]["name"] = serialize($role->name); + } + $tokenSerialized["expires"] = serialize($token->expires); $tokenSerialized["project"]["domainId"] = serialize($token->project->domainId); $tokenSerialized["project"]["parentId"] = serialize($token->project->parentId); @@ -124,6 +125,7 @@ class genTokenOptions $tokenSerialized["project"]["id"] = serialize($token->project->id); $tokenSerialized["project"]["links"] = serialize($token->project->links); $tokenSerialized["project"]["name"] = serialize($token->project->name); + foreach($token->catalog->services as $service){ $tokenSerialized["catalog"][serialize($service->id)]["name"] = serialize($service->name); $tokenSerialized["catalog"][serialize($service->id)]["description"] = serialize($service->description); @@ -158,14 +160,17 @@ class genTokenOptions $token = new Models\Token($this->httpClient, $api); $token->methods = unserialize($tokenSerialized["methods"]); $token->roles = []; + $i = 0; foreach($tokenSerialized["roles"] as $key => $role){ $tmp = new Models\Role($this->httpClient, $api); - $tmp->name = unserialize($key); + $tmp->id = unserialize($key); $tmp->links = unserialize($role["links"]); - $tmp->id = unserialize($role["id"]); + if(isset($role["name"])) + $tmp->name = unserialize($role["name"]); $token->roles[] = $tmp; + $i++; } $token->expires = unserialize($tokenSerialized["expires"]); @@ -178,7 +183,8 @@ class genTokenOptions $token->project->links = unserialize($tokenSerialized["project"]["links"]); $token->project->name = unserialize($tokenSerialized["project"]["name"]); - $token->catalog = []; + $token->catalog = new Models\Catalog($this->httpClient, $api); + $token->catalog->services = []; foreach($tokenSerialized["catalog"] as $key => $service){ $tmp = new Models\Service($this->httpClient, $api); @@ -198,8 +204,9 @@ class genTokenOptions $tmpEnd->url = unserialize($end["url"]); $tmp->endpoints[] = $tmpEnd; } - $tmp->links = unserialize($service["links"]); - $token->catalog[] = $tmp; + if(isset($service["links"])) + $tmp->links = unserialize($service["links"]); + $token->catalog->services[] = $tmp; } $token->extras = unserialize($tokenSerialized["extras"]); diff --git a/server/index.php b/server/index.php index c99e8bc..4d65c59 100755 --- a/server/index.php +++ b/server/index.php @@ -25,6 +25,6 @@ $computeTest = $openstackTest->computeV2($array); $serversTest = $computeTest->listServers(true); foreach($serversTest as $server){ - // echo $server->id." %%%%%% "; + echo $server->id." %%%%%% "; } // var_dump($openstack_api->getBuilderOptions()); -- cgit v1.2.3 From 4f062230bcfc8209776259af9c21fc34a29668e4 Mon Sep 17 00:00:00 2001 From: Eole Date: Sun, 31 Jan 2016 14:34:43 +0100 Subject: Implementation Token Multi Service ENd --- server/core/LibOverride/genTokenOptions.php | 12 +++++++----- server/index.php | 27 ++++++++++++++++----------- server/init.php | 6 +++--- 3 files changed, 26 insertions(+), 19 deletions(-) (limited to 'server/index.php') diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php index 3e8414e..9cb4100 100755 --- a/server/core/LibOverride/genTokenOptions.php +++ b/server/core/LibOverride/genTokenOptions.php @@ -56,9 +56,11 @@ class genTokenOptions $options['catalogType'] = 'false'; $options['region'] = 'RegionOne'; - list($token, $baseUrl) = $options['identityService']->authenticate($options); - - $this->stack->push(Middleware::authHandler($options['authHandler'], $token)); + //list($token, $baseUrl) = $options['identityService']->authenticate($options); + $baseUrl = $options["authUrl"]; + $token = $options['identityService']->generateToken($options); + + $this->stack->push(Middleware::authHandler($options['authHandler'], $token)); $this->addDebugMiddleware($options, $this->stack); @@ -227,8 +229,8 @@ class genTokenOptions return serialize($this->backup[$service]); } - public function getOptionsCompute(){ - return $this->optionsGlobal['Compute']; + public function getOptions($service){ + return $this->optionsGlobal[$service]; } private function serializeToken($token){ diff --git a/server/index.php b/server/index.php index 4d65c59..b3c061a 100755 --- a/server/index.php +++ b/server/index.php @@ -10,21 +10,26 @@ //$id = new identity($openstack_api, $pluginApi); // var_dump($id->genToken()); - $compute = $openstack_api->computeV2($array); - $servers = $compute->listServers(true); +// $identity = $openstack_api->identityV3($Args); + //$tmp = $identity->listEndpoints(); + //foreach($tmp as $cred){ +// echo $cred->id." %%%%%% "; + //} + //$servers = $compute->listServers(true); //var_dump($servers); - foreach($servers as $server){ + //foreach($servers as $server){ // echo $server->id." !!!!!!!!! "; - } + //} $tmp = new genTokenOptions($Args); - $tmp->loadComputeBackup($computBack); - $array = $tmp->getOptionsCompute(); + $tmp->loadIdentityBackup($identityBack); + $array = $tmp->getOptions("Identity"); $openstackTest = new OpenStack\OpenStack([]); - $computeTest = $openstackTest->computeV2($array); - $serversTest = $computeTest->listServers(true); - foreach($serversTest as $server){ - echo $server->id." %%%%%% "; + $identityTest = $openstackTest->identityV3($array); + $domainsTest = $identityTest->listDomains(); + foreach($domainsTest as $domain){ + echo $domain->id." %%%%%% "; } -// var_dump($openstack_api->getBuilderOptions()); + // var_dump($openstack_api->getBuilderOptions()); + diff --git a/server/init.php b/server/init.php index 9e0500b..2c07947 100755 --- a/server/init.php +++ b/server/init.php @@ -62,11 +62,11 @@ //$token = $id->genToken(); $tmp = new genTokenOptions($Args); - $tmp->genComputeToken(); - $array = $tmp->getOptionsCompute(); + $tmp->genIdentityToken(); + $array = $tmp->getOptions("Identity"); $openstack_api = new OpenStack\OpenStack([]); - $computBack = $tmp->getBackup("Compute"); + $identityBack = $tmp->getBackup("Identity"); //file_put_contents("token", serialize($tmp)); ?> -- cgit v1.2.3