airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [1/2] airavata-php-gateway git commit: adding the notion of authorized user to PGA
Date Fri, 04 Sep 2015 15:27:04 GMT
Repository: airavata-php-gateway
Updated Branches:
  refs/heads/master 2f3f5adc6 -> 64b06ccf4


adding the notion of authorized user to PGA


Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/1eba2ba1
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/1eba2ba1
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/1eba2ba1

Branch: refs/heads/master
Commit: 1eba2ba1bfa4d0c67578f15766fbd83d9b8fde1c
Parents: 2f3f5ad
Author: Supun Nakandala <scnakandala@apache.org>
Authored: Fri Sep 4 15:18:17 2015 +0530
Committer: Supun Nakandala <scnakandala@apache.org>
Committed: Fri Sep 4 15:18:17 2015 +0530

----------------------------------------------------------------------
 app/config/pga_config.php.template       |  2 +-
 app/controllers/AccountController.php    | 34 ++++++++++++---------------
 app/controllers/ExperimentController.php |  1 +
 app/controllers/ProjectController.php    |  1 +
 app/filters.php                          | 10 ++++++++
 app/libraries/CommonUtilities.php        |  3 ++-
 6 files changed, 30 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/1eba2ba1/app/config/pga_config.php.template
----------------------------------------------------------------------
diff --git a/app/config/pga_config.php.template b/app/config/pga_config.php.template
index 316b96b..89d95b2 100644
--- a/app/config/pga_config.php.template
+++ b/app/config/pga_config.php.template
@@ -16,7 +16,7 @@ return array(
         /**
          * Read only Admin Role Name
          */
-        'read-only-admin' => 'admin-read-only',
+        'read-only-admin-role-name' => 'admin-read-only',
 
         /**
          * Gateway user role

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/1eba2ba1/app/controllers/AccountController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index c8f66a5..b542b3b 100755
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -105,7 +105,7 @@ class AccountController extends BaseController
         if (in_array(Config::get('pga_config.wsis')['admin-role-name'], $userRoles)) {
             Session::put("admin", true);
         }
-        if (in_array(Config::get('pga_config.wsis')['read-only-admin'], $userRoles)) {
+        if (in_array(Config::get('pga_config.wsis')['read-only-admin-role-name'], $userRoles))
{
             Session::put("admin-read-only", true);
         }
 
@@ -113,9 +113,7 @@ class AccountController extends BaseController
         CommonUtilities::store_id_in_session($username);
         Session::put("gateway_id", Config::get('pga_config.airavata')['gateway-id']);
 
-        $this->initializeWithAiravata($username);
-
-        return Redirect::to("home");
+        return $this->initializeWithAiravata($username);
     }
 
     public function loginSubmit()
@@ -129,9 +127,12 @@ class AccountController extends BaseController
                     if (in_array(Config::get('pga_config.wsis')['admin-role-name'], $userRoles))
{
                         Session::put("admin", true);
                     }
-                    if (in_array(Config::get('pga_config.wsis')['read-only-admin'], $userRoles))
{
+                    if (in_array(Config::get('pga_config.wsis')['read-only-admin-role-name'],
$userRoles)) {
                         Session::put("admin-read-only", true);
                     }
+                    if (in_array(Config::get('pga_config.wsis')['user-role-name'], $userRoles))
{
+                        Session::put("authorized-user", true);
+                    }
 
                     $userProfile = WSIS::getUserProfile($username);
                     if($userProfile != null && !empty($userProfile)){
@@ -141,9 +142,7 @@ class AccountController extends BaseController
                     CommonUtilities::store_id_in_session($username);
                     Session::put("gateway_id", Config::get('pga_config.airavata')['gateway-id']);
 
-                    $this->initializeWithAiravata($username);
-
-                    return Redirect::to("home");
+                    return $this->initializeWithAiravata($username);
 
                 } else {
                     return Redirect::to("login")->with("invalid-credentials", true);
@@ -156,22 +155,19 @@ class AccountController extends BaseController
     }
 
     private function initializeWithAiravata($username){
-
         //Check Airavata Server is up
         try{
-            $apiVersion = Airavata::getAPIVersion();
-            if (empty($apiVersion))
-                return View::make("server-down");
+            //creating a default project for user
+            $projects = ProjectUtilities::get_all_user_projects(Config::get('pga_config.airavata')['gateway-id'],
$username);
+            if($projects == null || count($projects) == 0){
+                //creating a default project for user
+                ProjectUtilities::create_default_project($username);
+            }
         }catch (Exception $ex){
-            return View::make("server-down");
+            CommonUtilities::print_error_message("Unable to Connect to the Airavata Server
Instance!");
         }
 
-        //creating a default project for user
-        $projects = ProjectUtilities::get_all_user_projects(Config::get('pga_config.airavata')['gateway-id'],
$username);
-        if($projects == null || count($projects) == 0){
-            //creating a default project for user
-            ProjectUtilities::create_default_project($username);
-        }
+        return View::make("home");
     }
 
     public function forgotPassword()

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/1eba2ba1/app/controllers/ExperimentController.php
----------------------------------------------------------------------
diff --git a/app/controllers/ExperimentController.php b/app/controllers/ExperimentController.php
index a85f6e5..85ce991 100755
--- a/app/controllers/ExperimentController.php
+++ b/app/controllers/ExperimentController.php
@@ -16,6 +16,7 @@ class ExperimentController extends BaseController
     public function __construct()
     {
         $this->beforeFilter('verifylogin');
+        $this->beforeFilter('verifyauthorizeduser');
         Session::put("nav-active", "experiment");
     }
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/1eba2ba1/app/controllers/ProjectController.php
----------------------------------------------------------------------
diff --git a/app/controllers/ProjectController.php b/app/controllers/ProjectController.php
index 4f5d61a..f46cc0f 100755
--- a/app/controllers/ProjectController.php
+++ b/app/controllers/ProjectController.php
@@ -16,6 +16,7 @@ class ProjectController extends BaseController
     public function __construct()
     {
         $this->beforeFilter('verifylogin');
+        $this->beforeFilter('verifyauthorizeduser');
         Session::put("nav-active", "project");
 
     }

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/1eba2ba1/app/filters.php
----------------------------------------------------------------------
diff --git a/app/filters.php b/app/filters.php
index 97c6d63..182c2d2 100755
--- a/app/filters.php
+++ b/app/filters.php
@@ -104,6 +104,16 @@ Route::filter('verifylogin', function () {
         return Redirect::to("home")->with("login-alert", true);
 });
 
+Route::filter('verifyauthorizeduser', function () {
+    if (CommonUtilities::verify_login()) {
+        if (!(Session::has("admin") || Session::has("admin-read-only") || Session::has("authorized-user")))
{
+            return Redirect::to("home");
+        }
+    } else
+        return Redirect::to("home")->with("login-alert", true);
+});
+
+
 Route::filter('verifyadmin', function () {
     if (CommonUtilities::verify_login()) {
         if (!(Session::has("admin") || Session::has("admin-read-only"))) {

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/1eba2ba1/app/libraries/CommonUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/CommonUtilities.php b/app/libraries/CommonUtilities.php
index 0ba24d2..b4f6711 100644
--- a/app/libraries/CommonUtilities.php
+++ b/app/libraries/CommonUtilities.php
@@ -99,7 +99,8 @@ class CommonUtilities
     public static function create_nav_bar()
     {
         $menus = array();
-        if (Session::has('loggedin')) {
+        if (Session::has('loggedin') && (Session::has('authorizeduser') || Session::has('admin')
+                || Session::has('admin-read-only'))) {
             $menus = array
             (
                 'Project' => array


Mime
View raw message