Debut revoke
This commit is contained in:
parent
dde482df64
commit
a706b0d565
3 changed files with 92 additions and 38 deletions
|
@ -56,10 +56,10 @@ class App{
|
||||||
return $this->openstack->networkingV2($opt);
|
return $this->openstack->networkingV2($opt);
|
||||||
break;
|
break;
|
||||||
case "Compute":
|
case "Compute":
|
||||||
if($this->tokenPost == NULL) $this->tokenClass->genComputeToken();
|
if($this->tokenPost == NULL) $this->tokenClass->genComputeToken();
|
||||||
$opt = $this->tokenClass->getOptions($service);
|
$opt = $this->tokenClass->getOptions($service);
|
||||||
return $this->openstack->computeV2($opt);
|
return $this->openstack->computeV2($opt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,29 @@ class App{
|
||||||
$this->errorClass->BaseErrorHandler($e);
|
$this->errorClass->BaseErrorHandler($e);
|
||||||
}catch(NotImplementedError $e){
|
}catch(NotImplementedError $e){
|
||||||
$this->errorClass->NotImplementedHandler($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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,12 @@ class genTokenOptions
|
||||||
$this->optionsGlobal['Identity'] = $options;
|
$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){
|
public function loadIdentityBackup($opt){
|
||||||
$options = $this->optionsGlobal['Common'];
|
$options = $this->optionsGlobal['Common'];
|
||||||
$options['catalogName'] = 'false';
|
$options['catalogName'] = 'false';
|
||||||
|
@ -123,6 +129,12 @@ class genTokenOptions
|
||||||
$this->optionsGlobal['Image'] = $options;
|
$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){
|
public function loadImageBackup($opt){
|
||||||
$options = $this->optionsGlobal['Common'];
|
$options = $this->optionsGlobal['Common'];
|
||||||
$options['catalogName'] = 'glance';
|
$options['catalogName'] = 'glance';
|
||||||
|
@ -157,7 +169,7 @@ class genTokenOptions
|
||||||
|
|
||||||
$stack = HandlerStack::create();
|
$stack = HandlerStack::create();
|
||||||
|
|
||||||
$stack->push(Middleware::authHandler($options['authHandler'], $token));
|
$stack->push(Middleware::authHandler($options['authHandler'], $token));
|
||||||
|
|
||||||
$this->addDebugMiddleware($options, $stack);
|
$this->addDebugMiddleware($options, $stack);
|
||||||
|
|
||||||
|
@ -170,6 +182,12 @@ class genTokenOptions
|
||||||
$this->optionsGlobal['Network'] = $options;
|
$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){
|
public function loadNetworkBackup($opt){
|
||||||
$options = $this->optionsGlobal['Common'];
|
$options = $this->optionsGlobal['Common'];
|
||||||
$options['catalogName'] = 'neutron';
|
$options['catalogName'] = 'neutron';
|
||||||
|
@ -217,6 +235,12 @@ class genTokenOptions
|
||||||
$this->optionsGlobal['Compute'] = $options;
|
$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){
|
public function loadComputeBackup($opt){
|
||||||
|
|
||||||
$options = $this->optionsGlobal['Common'];
|
$options = $this->optionsGlobal['Common'];
|
||||||
|
@ -245,7 +269,7 @@ class genTokenOptions
|
||||||
private function saveBackup($name, $data){
|
private function saveBackup($name, $data){
|
||||||
$token = $this->serializeToken($data["token"]);
|
$token = $this->serializeToken($data["token"]);
|
||||||
$path = "core/LibOverride/projectTokenData/".$token['saved']["project"]["name"];
|
$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']));
|
file_put_contents("core/LibOverride/projectTokenData/".$token['saved']["project"]["name"], serialize($token['saved']));
|
||||||
$this->backup["roles"] = $token["roles"];
|
$this->backup["roles"] = $token["roles"];
|
||||||
$this->backup["project"] = $token['saved']["project"]["name"];
|
$this->backup["project"] = $token['saved']["project"]["name"];
|
||||||
|
|
70
server/index.php
Normal file → Executable file
70
server/index.php
Normal file → Executable file
|
@ -6,7 +6,7 @@
|
||||||
if(isset($_POST["task"]) && isset($_POST["action"])){
|
if(isset($_POST["task"]) && isset($_POST["action"])){
|
||||||
$task = $_POST["task"];
|
$task = $_POST["task"];
|
||||||
$action = $_POST["action"];
|
$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"];
|
$task = $_POST["task"];
|
||||||
}else{
|
}else{
|
||||||
//Gestion Erreur
|
//Gestion Erreur
|
||||||
|
@ -17,36 +17,44 @@
|
||||||
$App->authenticate();
|
$App->authenticate();
|
||||||
$App->show();
|
$App->show();
|
||||||
|
|
||||||
|
}else if($task == "Deauthenticate"){
|
||||||
|
|
||||||
|
$App->deauthenticate();
|
||||||
|
$App->show();
|
||||||
|
|
||||||
|
}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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue