From 795123583e4a14005582f2f3176403ec2db54fb4 Mon Sep 17 00:00:00 2001 From: disc5 Date: Mon, 13 Jul 2015 16:26:02 +0200 Subject: [PATCH] Release 0.9 Fixed auto-login into Restplugin Administration --- .../core/auth/models/MiscEndpoint.php | 21 +++++++++++++++---- .../RESTController/core/auth/models/Util.php | 4 ++-- .../REST/apps/admin/index.php | 3 +++ .../REST/apps/admin/js/controllers.js | 2 +- .../REST/classes/class.ilRESTConfigGUI.php | 1 + .../UserInterfaceHook/REST/plugin.php | 6 +++--- 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/core/auth/models/MiscEndpoint.php b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/core/auth/models/MiscEndpoint.php index a0d40641..bba1c3f9 100644 --- a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/core/auth/models/MiscEndpoint.php +++ b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/core/auth/models/MiscEndpoint.php @@ -2,8 +2,8 @@ /** * ILIAS REST Plugin for the ILIAS LMS * - * Authors: D.Schaefer, S.Schneider and T. Hufschmidt <(schaefer|schneider|hufschmidt)@hrz.uni-marburg.de> - * 2014-2015 + * Authors: D.Schaefer and T. Hufschmidt <(schaefer|hufschmidt)@hrz.uni-marburg.de> + * Since 2014 */ namespace RESTController\core\auth; @@ -49,13 +49,26 @@ public function tokenInfo($accessToken) { * @param $app */ public function rToken2Bearer($api_key, $user_id, $rtoken, $session_id) { + $utils = new Util(); // Check login-data - if (!$this->checkSession($user_id, $rtoken, $session_id)) + if (!$utils->checkSession($user_id, $rtoken, $session_id)) { throw new Exceptions\TokenInvalid(self::MSG_RTOKEN_AUTH_FAILED); + } // Generate token for user (via given api-key) $user = Libs\RESTLib::getUserNameFromId($user_id); $bearerToken = Token\Bearer::fromFields(self::tokenSettings(), $user, $api_key); - return $bearerToken->getTokenArray(); + + $accessToken = $bearerToken->getEntry('access_token'); + + // + return array( + 'access_token' => $accessToken->getTokenString(), + 'expires_in' => $bearerToken->getEntry('expires_in'), + 'token_type' => $bearerToken->getEntry('token_type'), + 'scope' => $bearerToken->getEntry('scope') + ); + + //return $bearerToken->getTokenArray(); } } diff --git a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/core/auth/models/Util.php b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/core/auth/models/Util.php index 4435d7a2..dd18e225 100644 --- a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/core/auth/models/Util.php +++ b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/core/auth/models/Util.php @@ -2,8 +2,8 @@ /** * ILIAS REST Plugin for the ILIAS LMS * - * Authors: D.Schaefer, S.Schneider and T. Hufschmidt <(schaefer|schneider|hufschmidt)@hrz.uni-marburg.de> - * 2014-2015 + * Authors: D.Schaefer and T. Hufschmidt <(schaefer|hufschmidt)@hrz.uni-marburg.de> + * Since 2014 */ namespace RESTController\core\auth; diff --git a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/apps/admin/index.php b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/apps/admin/index.php index 8d835dc9..55fd18a7 100755 --- a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/apps/admin/index.php +++ b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/apps/admin/index.php @@ -29,12 +29,14 @@ diff --git a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/apps/admin/js/controllers.js b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/apps/admin/js/controllers.js index b151e4b0..05dbbbac 100755 --- a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/apps/admin/js/controllers.js +++ b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/apps/admin/js/controllers.js @@ -433,7 +433,7 @@ ctrl.controller('LoginCtrl', function($scope, $location, $filter, apiKey, restAu // Login return OK (Login internally and redirect) if (response.status == "success") { $scope.postVars = {}; - $scope.authentication.login(response.user, response.token.access_token); + $scope.authentication.login(response.user, response.access_token); $location.url("/clientlist"); $scope.$emit('loginPerformed'); // Login didn't return an OK (Logout internally and redirdct) diff --git a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/classes/class.ilRESTConfigGUI.php b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/classes/class.ilRESTConfigGUI.php index d67fce22..cb10344b 100755 --- a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/classes/class.ilRESTConfigGUI.php +++ b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/classes/class.ilRESTConfigGUI.php @@ -71,6 +71,7 @@ function configure() { + '; diff --git a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/plugin.php b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/plugin.php index 65f7f2c8..e30900ff 100755 --- a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/plugin.php +++ b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/plugin.php @@ -8,10 +8,10 @@ $id = "rest"; -$version = "0.8"; +$version = "0.9"; $ilias_min_version = "4.0.0"; $ilias_max_version = "5.2.0"; -$responsible = "D.Schaefer, S.Schneider, T.Hufschmidt"; -$responsible_mail = "{schaefer|schneider|hufschmidt} at hrz.uni-marburg.de"; +$responsible = "D.Schaefer, T.Hufschmidt"; +$responsible_mail = "{schaefer|hufschmidt} at hrz.uni-marburg.de";