Debut revoke

This commit is contained in:
EoleDev 2016-03-09 14:53:48 +01:00
parent dde482df64
commit a706b0d565
3 changed files with 92 additions and 38 deletions

View file

@ -85,6 +85,28 @@ class App{
}
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);
}
}
public function getPostParam($name){
return $this->postParams[$name];

View file

@ -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';
@ -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"];

12
server/index.php Normal file → Executable file
View file

@ -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,8 +17,12 @@
$App->authenticate();
$App->show();
}
}else if($task == "Deauthenticate"){
$App->deauthenticate();
$App->show();
}else{
switch($task)
{
case "identity":
@ -50,3 +54,7 @@
break;
}
}