diff --git a/gulliver/system/class.g.php b/gulliver/system/class.g.php index 50e3a60f1..9f67b7d26 100755 --- a/gulliver/system/class.g.php +++ b/gulliver/system/class.g.php @@ -5175,16 +5175,18 @@ function getDirectorySize($path,$maxmtime=0) $rest = new Restler(); $rest->setSupportedFormats('JsonFormat', 'XmlFormat'); + $namespace = 'Services_Rest_'; // override global REQUEST_URI to pass to Restler library - $_SERVER['REQUEST_URI'] = $uri; + $_SERVER['REQUEST_URI'] = '/' . strtolower($namespace) . ltrim($uri, '/'); // getting all services class $srvClasses = glob(PATH_SERVICES_REST . '*.php'); foreach ($srvClasses as $classFile) { require_once $classFile; - $className = str_replace('.php', '', basename($classFile)); + + $className = $namespace . str_replace('.php', '', basename($classFile)); $reflClass = new ReflectionClass($className); // verify if there is an auth class implementing 'iAuthenticate' diff --git a/workflow/engine/services/rest/Application.php b/workflow/engine/services/rest/Application.php index d4b58c0fc..5a7af0e07 100644 --- a/workflow/engine/services/rest/Application.php +++ b/workflow/engine/services/rest/Application.php @@ -1,18 +1,21 @@ getAll($userUid, $start=null, $limit=null, $action=null); + $app = new Applications(); + $userUid = Services_Rest_Auth::$userId; + + return $app->getAll($userUid, $start, $limit, $type); } else { // get a specific record. G::loadClass('wsBase'); - $case = new wsBase(); - $case->getCaseInfo($id); + $wsBase = new wsBase(); + return $wsBase->getCaseInfo($id); } } } diff --git a/workflow/engine/services/rest/Auth.php b/workflow/engine/services/rest/Auth.php index 0ddea0807..337e09886 100644 --- a/workflow/engine/services/rest/Auth.php +++ b/workflow/engine/services/rest/Auth.php @@ -2,10 +2,13 @@ G::LoadClass('sessions'); G::LoadClass('wsBase'); -class Auth implements iAuthenticate +class Services_Rest_Auth implements iAuthenticate { public $realm = 'Restricted API'; + public static $userId = ''; + public static $authKey = ''; + function __isAuthenticated() { if (array_key_exists('HTTP_AUTH_KEY', $_SERVER)) { @@ -20,18 +23,13 @@ class Auth implements iAuthenticate $session = $sessions->verifySession($authKey); if (is_array($session)) { + $sesInfo = $sessions->getSessionUser($authKey); + self::$userId = $sesInfo['USR_UID']; + self::$authKey = $authKey; + return true; } throw new RestException(401, 'Wrong Credentials!'); } - - /** - * @url POST - */ - public function login($user, $passwd) - { - $wsBase = new wsBase(); - return $wsBase->login($user, $passwd); - } } diff --git a/workflow/engine/services/rest/Login.php b/workflow/engine/services/rest/Login.php index 36440c045..dfb859728 100644 --- a/workflow/engine/services/rest/Login.php +++ b/workflow/engine/services/rest/Login.php @@ -2,7 +2,7 @@ G::loadClass('wsBase'); G::LoadClass('sessions'); -class Login +class Services_Rest_Login { public function post($user, $passwd) { @@ -12,7 +12,6 @@ class Login if ($result->status_code == 0) { return array( 'auth_key' => $result->message, - //'timestamp' => $result->timestamp, ); } else { throw new RestException(401, $result->message);