Skip to content

Commit

Permalink
Release 0.9
Browse files Browse the repository at this point in the history
Fixed auto-login into Restplugin Administration
  • Loading branch information
disc5 committed Jul 13, 2015
1 parent cef9515 commit 7951235
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@
<script>
<?php
// Fetch POST data
$apiKey = isset($_POST['apiKey']) ? $_POST['apiKey'] : '';
$userId = isset($_POST['userId']) ? $_POST['userId'] : '';
$sessionId = isset($_POST['sessionId']) ? $_POST['sessionId'] : '';
$rtoken = isset($_POST['rtoken']) ? $_POST['rtoken'] : '';
$restEndpoint = isset($_POST['restEndpoint']) ? $_POST['restEndpoint'] : '';

// Make it save
$apiKey = addslashes (htmlspecialchars($apiKey, ENT_COMPAT | ENT_HTML5));
$userId = addslashes (htmlspecialchars($userId, ENT_COMPAT | ENT_HTML5));
$sessionId = addslashes (htmlspecialchars($sessionId, ENT_COMPAT | ENT_HTML5));
$rtoken = addslashes (htmlspecialchars($rtoken, ENT_COMPAT | ENT_HTML5));
Expand All @@ -46,6 +48,7 @@
sessionId: "<?php echo $sessionId; ?>",
rtoken: "<?php echo $rtoken; ?>",
restEndpoint: "<?php echo $restEndpoint; ?>",
apiKey: "<?php echo $apiKey; ?>"
};
</script>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function configure() {
<input type="hidden" name="sessionId" value="'.session_id().'" />
<input type="hidden" name="rtoken" value="'.$ilCtrl->rtoken.'" />
<input type="hidden" name="restEndpoint" value="'.$inst_folder.'" />
<input type="hidden" name="apiKey" value="apollon" />
<input type="submit" class="btn btn-default" value="'.$pl->txt("button_redirect").'" />
</form>
';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

0 comments on commit 7951235

Please sign in to comment.