diff options
Diffstat (limited to 'server')
| -rwxr-xr-x | server/core/App.php | 32 | ||||
| -rwxr-xr-x | server/core/LibOverride/genTokenOptions.php | 28 | ||||
| -rwxr-xr-x[-rw-r--r--] | server/index.php | 68 |
3 files changed, 91 insertions, 37 deletions
diff --git a/server/core/App.php b/server/core/App.php index edb75f6..de886a6 100755 --- a/server/core/App.php +++ b/server/core/App.php @@ -56,10 +56,10 @@ class App{ return $this->openstack->networkingV2($opt);
break;
case "Compute":
- if($this->tokenPost == NULL) $this->tokenClass->genComputeToken();
- $opt = $this->tokenClass->getOptions($service);
- return $this->openstack->computeV2($opt);
- break;
+ if($this->tokenPost == NULL) $this->tokenClass->genComputeToken();
+ $opt = $this->tokenClass->getOptions($service);
+ return $this->openstack->computeV2($opt);
+ break;
}
}
@@ -81,7 +81,29 @@ class App{ $this->errorClass->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->errorClass->NotImplementedHandler($e);
- }
+ }
+
+ }
+
+ public function deauthenticate(){
+
+ try{
+
+ $this->tokenClass->revokeComputeToken();
+ $this->tokenClass->revokeImageToken();
+ $this->tokenClass->revokeNetworkToken();
+ $this->tokenClass->revokeIdentityToken();
+
+ $this->setOutput("deauthenticate", "Ok");
+ }catch(BadResponseError $e){
+ $this->errorClass->BadResponseHandler($e);
+ }catch(UserInputError $e){
+ $this->errorClass->UserInputHandler($e);
+ }catch(BaseError $e){
+ $this->errorClass->BaseErrorHandler($e);
+ }catch(NotImplementedError $e){
+ $this->errorClass->NotImplementedHandler($e);
+ }
}
diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php index 50826ed..47f026a 100755 --- a/server/core/LibOverride/genTokenOptions.php +++ b/server/core/LibOverride/genTokenOptions.php @@ -75,6 +75,12 @@ class genTokenOptions $this->optionsGlobal['Identity'] = $options; } + public function revokeIdentityToken(){ + $token = $this->unserializeToken($this->backup['Identity']['token']); + $this->optionsGlobal['Common']['identityService']->revokeToken($token->id); + + } + public function loadIdentityBackup($opt){ $options = $this->optionsGlobal['Common']; $options['catalogName'] = 'false'; @@ -123,6 +129,12 @@ class genTokenOptions $this->optionsGlobal['Image'] = $options; } + public function revokeImageToken(){ + $token = $this->unserializeToken($this->backup['Image']['token']); + $this->optionsGlobal['Common']['identityService']->revokeToken($token->id); + + } + public function loadImageBackup($opt){ $options = $this->optionsGlobal['Common']; $options['catalogName'] = 'glance'; @@ -157,7 +169,7 @@ class genTokenOptions $stack = HandlerStack::create(); - $stack->push(Middleware::authHandler($options['authHandler'], $token)); + $stack->push(Middleware::authHandler($options['authHandler'], $token)); $this->addDebugMiddleware($options, $stack); @@ -170,6 +182,12 @@ class genTokenOptions $this->optionsGlobal['Network'] = $options; } + public function revokeNetworkToken(){ + $token = $this->unserializeToken($this->backup['Network']['token']); + $this->optionsGlobal['Common']['identityService']->revokeToken($token->id); + + } + public function loadNetworkBackup($opt){ $options = $this->optionsGlobal['Common']; $options['catalogName'] = 'neutron'; @@ -217,6 +235,12 @@ class genTokenOptions $this->optionsGlobal['Compute'] = $options; } + public function revokeComputeToken(){ + $token = $this->unserializeToken($this->backup['Compute']['token']); + $this->optionsGlobal['Common']['identityService']->revokeToken($token->id); + + } + public function loadComputeBackup($opt){ $options = $this->optionsGlobal['Common']; @@ -245,7 +269,7 @@ class genTokenOptions private function saveBackup($name, $data){ $token = $this->serializeToken($data["token"]); $path = "core/LibOverride/projectTokenData/".$token['saved']["project"]["name"]; - error_log(print_r($path, true), 0); + //error_log(print_r($path, true), 0); file_put_contents("core/LibOverride/projectTokenData/".$token['saved']["project"]["name"], serialize($token['saved'])); $this->backup["roles"] = $token["roles"]; $this->backup["project"] = $token['saved']["project"]["name"]; diff --git a/server/index.php b/server/index.php index f888671..31feb08 100644..100755 --- a/server/index.php +++ b/server/index.php @@ -6,7 +6,7 @@ if(isset($_POST["task"]) && isset($_POST["action"])){ $task = $_POST["task"]; $action = $_POST["action"]; - }else if(isset($_POST["task"]) && $_POST["task"] == "Authenticate"){ + }else if(isset($_POST["task"]) && $_POST["task"] == "Authenticate" || $_POST["task"] == "Deauthenticate"){ $task = $_POST["task"]; }else{ //Gestion Erreur @@ -17,36 +17,44 @@ $App->authenticate(); $App->show(); - } - - switch($task) - { - case "identity": - include_once("core/Identity.php"); - $identityObject = new identity($App); - $identityObject->action($action); - $App->show(); - break; + }else if($task == "Deauthenticate"){ + + $App->deauthenticate(); + $App->show(); - case "network": - include_once("core/Network.php"); - $networkObject = new network($App); - $networkObject->action($action); - $App->show(); - break; + }else{ + switch($task) + { + case "identity": + include_once("core/Identity.php"); + $identityObject = new identity($App); + $identityObject->action($action); + $App->show(); + break; + + case "network": + include_once("core/Network.php"); + $networkObject = new network($App); + $networkObject->action($action); + $App->show(); + break; + + case "image": + include_once("core/Image.php"); + $imageObject = new image($App); + $imageObject->action($action); + $App->show(); + break; + + case "compute": + include_once("core/Compute.php"); + $computeObject = new compute($App); + $computeObject->action($action); + $App->show(); + break; + } - case "image": - include_once("core/Image.php"); - $imageObject = new image($App); - $imageObject->action($action); - $App->show(); - break; - - case "compute": - include_once("core/Compute.php"); - $computeObject = new compute($App); - $computeObject->action($action); - $App->show(); - break; } + + |
