Commit 47ef4864379588ff087bd48ab081c15e37c12b2f

Authored by Nathanael Jourdane
1 parent 6104c71e

Set timeLimit in config.php and set it to 10minutes.

php/classes/WebServer.php
... ... @@ -5,6 +5,9 @@
5 5 *
6 6 * @version $Id: WebServer.php 2968 2015-06-29 13:17:00Z natacha $
7 7 */
  8 +
  9 +require_once '../config.php';
  10 +
8 11 class WebResultMgr
9 12 {
10 13 private $resDOM;
... ... @@ -83,7 +86,6 @@ class WebServer
83 86 private $wsUserMgr;
84 87 private $resultMgr, $myParamsInfoMgr;
85 88 private $dataFileName;
86   - private $timeLimitQuery; // Time interval between 2 queries before to ask for a new authentification, in seconds.
87 89  
88 90 function __construct() {
89 91 $this->userID = 'impex';
... ... @@ -91,7 +93,6 @@ class WebServer
91 93 $this->sessionID = $this->userID;
92 94 $this->myParamsInfoMgr = new ParamsInfoMgr();
93 95 $this->resultMgr = new WebResultMgr();
94   - $this->timeLimitQuery = 30;
95 96 }
96 97  
97 98 protected function init($data) {
... ... @@ -551,7 +552,8 @@ class WebServer
551 552  
552 553 public function getNewToken() {
553 554 $timeStamp = (new DateTime())->getTimestamp();
554   - $newToken = md5((int)($timeStamp/30));
  555 + // generate token from timeStamp and some salt
  556 + $newToken = md5(1321 * (int)($timeStamp/timeLimitQuery));
555 557 return array('success' => true, 'token' => $newToken);
556 558 }
557 559  
... ...
php/config.php
... ... @@ -118,6 +118,9 @@ $SERVER_NAME = $_SERVER['SERVER_NAME'] ? $_SERVER['SERVER_NAME'] : gethostname(
118 118  
119 119 define('webAlias',"http://".$SERVER_NAME.APACHE_ALIAS);
120 120 define('wsdl_AMDA', webAlias."public/wsdl/Methods_AMDA.wsdl");
  121 +
  122 +// Time interval between 2 queries before to ask for a new authentification, in seconds.
  123 +define ('timeLimitQuery', 600);
121 124 /*-------------------END WEB SERVICES section ---------*/
122 125  
123 126 // AKKA - KERNELBIN is now the new kernel bin dir
... ...
php/rest/auth.php
... ... @@ -12,7 +12,7 @@
12 12 require_once '../config.php';
13 13  
14 14 $amda_ws = new WebServer();
15   - $result = $amda_ws->auth($_GET);
  15 + $result = $amda_ws->getNewToken($_GET);
16 16  
17 17 if ($result['success']){
18 18 echo $result['token'];
... ...