Time maagement on token
This commit is contained in:
parent
a2f120aa73
commit
f9643dd9ff
4 changed files with 18 additions and 2 deletions
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
$config["modules_enabled"] = "";
|
$config["modules_enabled"] = "";
|
||||||
$config["urlAuth"] = "http://148.60.11.31:5000/v3";
|
$config["urlAuth"] = "http://148.60.11.31:5000/v3";
|
||||||
|
$config["tokenTime"] = 60 //miunte = 60 //miuntess
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,10 @@ class App{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function checkToken(){
|
||||||
|
$this->tokenClass->checkToken();
|
||||||
|
}
|
||||||
|
|
||||||
public function getLibClass($service){
|
public function getLibClass($service){
|
||||||
|
|
||||||
switch($service){
|
switch($service){
|
||||||
|
|
|
@ -49,6 +49,12 @@ class genTokenOptions
|
||||||
$stack->push(GuzzleMiddleware::log($options['logger'], $options['messageFormatter']));
|
$stack->push(GuzzleMiddleware::log($options['logger'], $options['messageFormatter']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function checkToken(){
|
||||||
|
|
||||||
|
return $this->backup['time'] > time();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function genIdentityToken(){
|
public function genIdentityToken(){
|
||||||
$options = $this->optionsGlobal['Common'];
|
$options = $this->optionsGlobal['Common'];
|
||||||
|
@ -271,6 +277,7 @@ class genTokenOptions
|
||||||
$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['time'] = $token['time'];
|
||||||
$this->backup["roles"] = $token["roles"];
|
$this->backup["roles"] = $token["roles"];
|
||||||
$this->backup["project"] = $token['saved']["project"]["name"];
|
$this->backup["project"] = $token['saved']["project"]["name"];
|
||||||
$this->backup["user"] = $token["user"];
|
$this->backup["user"] = $token["user"];
|
||||||
|
@ -284,7 +291,7 @@ class genTokenOptions
|
||||||
public function loadBackup($back){
|
public function loadBackup($back){
|
||||||
|
|
||||||
$backup = unserialize($back);
|
$backup = unserialize($back);
|
||||||
|
$this->backup['time'] = $backup['time'];
|
||||||
$this->backup["roles"] = $backup["roles"];
|
$this->backup["roles"] = $backup["roles"];
|
||||||
$this->backup["project"] = $backup["project"];
|
$this->backup["project"] = $backup["project"];
|
||||||
$this->backup["user"] = $backup["user"];
|
$this->backup["user"] = $backup["user"];
|
||||||
|
@ -343,6 +350,7 @@ class genTokenOptions
|
||||||
$tokenSerialized["user"]["name"] = serialize($token->user->name);
|
$tokenSerialized["user"]["name"] = serialize($token->user->name);
|
||||||
$tokenSerialized["token"]["issued"] = serialize($token->issued);
|
$tokenSerialized["token"]["issued"] = serialize($token->issued);
|
||||||
$tokenSerialized["token"]["id"] = serialize($token->id);
|
$tokenSerialized["token"]["id"] = serialize($token->id);
|
||||||
|
$tokenSerialized['time'] = time()+$config['tokenTime']*60;
|
||||||
|
|
||||||
return $tokenSerialized;
|
return $tokenSerialized;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
$App->deauthenticate();
|
$App->deauthenticate();
|
||||||
$App->show();
|
$App->show();
|
||||||
|
|
||||||
}else{
|
}else if($App->checkToken()){
|
||||||
switch($task)
|
switch($task)
|
||||||
{
|
{
|
||||||
case "identity":
|
case "identity":
|
||||||
|
@ -54,6 +54,9 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$App->setOuptut("Error", "Token Invalide");
|
||||||
|
$App->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue