Commit 1e8c4961e51674bcb01c76feeccfa5238bb99089

Authored by Benjamin Renard
1 parent 2e4a962c

Automatic user registration (#6978)

Showing 2 changed files with 32 additions and 3 deletions   Show diff stats
php/classes/AmdaClient.php
... ... @@ -28,6 +28,10 @@ class AmdaClient {
28 28 date_default_timezone_set('UTC');
29 29 }
30 30  
  31 + public function base64url_encode($data) {
  32 + return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
  33 + }
  34 +
31 35 /* Just copy URL to Info/Bases.xml */
32 36 public function getAvailableExternalBases() {
33 37 try {
... ... @@ -230,13 +234,40 @@ class AmdaClient {
230 234 /* Get user info from login */
231 235 public function getUserInfo($login) {
232 236 try {
233   - $info = $this->client->getUserInfo($login,md5(DDSERVICE_PRIVATEKEY.$login.'getUserInfo'));
  237 + $data_array = array(
  238 + "login" => $login,
  239 + "timestamp" => time(),
  240 + );
  241 + $data = $this->base64url_encode(json_encode($data_array));
  242 + $check = md5($data.DDSERVICE_PUBLICKEY.DDSERVICE_PRIVATEKEY);
  243 + $info = $this->client->getUserInfo($data,DDSERVICE_PUBLICKEY,$check);
234 244 }
235 245 catch (SoapFault $exception) {
236 246 return array('success' => false, 'message' => $exception->faultstring);
237 247 }
238 248 return $info;
239 249 }
  250 +
  251 + /* Create a new user */
  252 + public function createUser($login, $pwd, $first_name, $last_name, $email) {
  253 + $result = FALSE;
  254 + try {
  255 + $data_array = array(
  256 + "login" => $login,
  257 + "pwd" => $pwd,
  258 + "first_name" => $first_name,
  259 + "last_name" => $last_name,
  260 + "email" => $email,
  261 + "timestamp" => time(),
  262 + );
  263 + $data = $this->base64url_encode(json_encode($data_array));
  264 + $check = md5($data.DDSERVICE_PUBLICKEY.DDSERVICE_PRIVATEKEY);
  265 + $result = $this->client->createUser($data,DDSERVICE_PUBLICKEY,$check);
  266 + }
  267 + catch (SoapFault $exception) {
  268 + }
  269 + return $result;
  270 + }
240 271  
241 272 /* Get data set info */
242 273 // public function getInfo($viID, $infoID) {
... ...
php/config.php
... ... @@ -48,8 +48,6 @@ define("MaxGuestTimeInterval", 10); // days
48 48 define('DISK_QUOTA_standard', 1024*1024*200); // 200MB
49 49 // max lines of uploaded ascii file to show
50 50 define('MAX_FILE_INDEX_TO_SHOW', 100);
51   -// private key used to be considerate as a trust client for some functions of DD web service
52   -define('DDSERVICE_PRIVATEKEY', '!%p856Dc');
53 51  
54 52 // EPN-TAP services
55 53 define('EPNTAP_APIS', 'http://voparis-tap.obspm.fr/__system__/tap/run/tap/sync');
... ...