Skip to content
Permalink
Browse files
considering the less priviledged user case
  • Loading branch information
scnakandala committed Jun 28, 2017
1 parent a3cd053 commit b1dcbdfa0ccebb213d44e6a1277943a6c47a10b3
Showing 2 changed files with 22 additions and 15 deletions.
@@ -170,16 +170,12 @@ public function loginSubmit()
Session::put("gateway_id", Config::get('pga_config.airavata')['gateway-id']);

if(Session::has("admin") || Session::has("admin-read-only") || Session::has("authorized-user")){
return $this->initializeWithAiravata($username, $userEmail, $firstName, $lastName, $accessToken, $refreshToken, $expirationTime);
return $this->initializeWithAiravata($username, $userEmail, $firstName, $lastName, $accessToken,
$refreshToken, $expirationTime);
}

if(Session::has("admin") || Session::has("admin-read-only")){
return Redirect::to("admin/dashboard". "?status=ok&code=".$accessToken . "&username=".$username
. "&refresh_code=" . $refreshToken . "&valid_time=" . $expirationTime);
}else{
return Redirect::to("account/dashboard". "?status=ok&code=".$accessToken . "&username=".$username
. "&refresh_code=" . $refreshToken . "&valid_time=" . $expirationTime);
}
return Redirect::to("account/dashboard" . "?status=less_privileged&code=".$accessToken . "&username=".$username
. "&refresh_code=" . $refreshToken . "&valid_time=" . $expirationTime);
}

}
@@ -246,13 +242,9 @@ public function oauthCallback()
return $this->initializeWithAiravata($username, $userEmail, $firstName, $lastName, $accessToken, $refreshToken, $expirationTime);
}

if(Session::has("admin") || Session::has("admin-read-only")){
return Redirect::to("admin/dashboard" . "?status=ok&code=" . $accessToken . "&username=".$username
. "&refresh_code=" . $refreshToken . "&valid_time=" . $expirationTime);
}else{
return Redirect::to("account/dashboard" . "?status=ok&code=".$accessToken . "&username=".$username
. "&refresh_code=" . $refreshToken . "&valid_time=" . $expirationTime);
}
return Redirect::to("account/dashboard" . "?status=less_privileged&code=".$accessToken . "&username=".$username
. "&refresh_code=" . $refreshToken . "&valid_time=" . $expirationTime);

}

private function hasAnyRoles($roles) {
@@ -495,6 +487,19 @@ public function resetPasswordSubmit()
}
}

public function getRefreshedTokenForDesktop(){
$refreshToken = Input::get('refresh_code');
$response = Keycloak::getRefreshedOAuthToken($refreshToken);
if(isset($response->access_token)){
$accessToken = $response->access_token;
$refreshToken = $response->refresh_token;
$expirationTime = $response->expires_in; // 5 minutes safe margin
var_dump(array('status'=>'ok', 'code'=>$accessToken, 'refresh_code'=>$refreshToken, 'valid_time'=>$expirationTime));
}else{
var_dump(array('status'=>'failed'));
}
}

public function logout()
{
Session::flush();
@@ -24,6 +24,8 @@

Route::get("login-desktop", "AccountController@loginDesktopView");

Route::get("refreshed-token-desktop", "AccountController@getRefreshedTokenForDesktop");

Route::get("account/dashboard", "AccountController@dashboard");

Route::get("callback-url", "AccountController@oauthCallback");

0 comments on commit b1dcbdf

Please sign in to comment.