airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndo...@apache.org
Subject [5/6] airavata-php-gateway git commit: Reomve Token implementation
Date Fri, 11 Dec 2015 18:31:07 GMT
Reomve Token implementation


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/1f0c64f1
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/1f0c64f1
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/1f0c64f1

Branch: refs/heads/master
Commit: 1f0c64f18107d2e52203b7107a14f14169db5666
Parents: f67d850
Author: Nipurn Doshi <nipunhere@gmail.com>
Authored: Fri Dec 11 13:28:15 2015 -0500
Committer: Nipurn Doshi <nipunhere@gmail.com>
Committed: Fri Dec 11 13:28:15 2015 -0500

----------------------------------------------------------------------
 app/controllers/AdminController.php          |  6 +++
 app/libraries/AdminUtilities.php             | 15 +++++++
 app/routes.php                               |  4 +-
 app/views/admin/manage-credentials.blade.php | 51 ++++++++++++++++++++++-
 4 files changed, 73 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/1f0c64f1/app/controllers/AdminController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php
index 855d274..dd08220 100644
--- a/app/controllers/AdminController.php
+++ b/app/controllers/AdminController.php
@@ -221,4 +221,10 @@ class AdminController extends BaseController {
 
 	}
 
+	public function removeSSH(){
+		$removeToken = Input::get("token");
+		return AdminUtilities::remove_ssh_token( $removeToken);
+
+	}
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/1f0c64f1/app/libraries/AdminUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/AdminUtilities.php b/app/libraries/AdminUtilities.php
index 90ad544..b8576c4 100644
--- a/app/libraries/AdminUtilities.php
+++ b/app/libraries/AdminUtilities.php
@@ -93,4 +93,19 @@ class AdminUtilities
     public static function get_pubkey_from_token( $token){
         return Airavata::getSSHPubKey( Session::get('authz-token'), $token, Session::get("gateway_id"));
     }
+
+    public static function remove_ssh_token( $token){
+        try{
+            return Airavata::deleteSSHPubKey( Session::get('authz-token'), $token, Session::get("gateway_id"));
+        } catch (InvalidRequestException $ire) {
+            CommonUtilities::print_error_message('p>Error in creating SSH Handshake. You
might have to enable TLS in pga_config. </p>' .
+                '<p>InvalidRequestException: ' . $ire->getMessage() . '</p>');
+        } catch (AiravataClientException $ace) {
+            CommonUtilities::print_error_message('<p>Error in creating SSH Handshake.
You might have to enable TLS in pga_config.  </p>' .
+                '<p>Airavata Client Exception: ' . $ace->getMessage() . '</p>');
+        } catch (AiravataSystemException $ase) {
+            CommonUtilities::print_error_message('p>Error in creating SSH Handshake. You
might have to enable TLS in pga_config.  </p>' .
+                '<p>Airavata System Exception: ' . $ase->getMessage() . '</p>');
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/1f0c64f1/app/routes.php
----------------------------------------------------------------------
diff --git a/app/routes.php b/app/routes.php
index 4aa4dc3..474babb 100755
--- a/app/routes.php
+++ b/app/routes.php
@@ -236,7 +236,9 @@ Route::post("admin/add-roles-to-user", "AdminController@addRolesToUser");
 
 Route::post("admin/remove-role-from-user", "AdminController@removeRoleFromUser");
 
-Route::post("create-ssh-token", "AdminController@createSSH");
+Route::post("admin/create-ssh-token", "AdminController@createSSH");
+
+Route::post("admin/remove-ssh-token", "AdminController@removeSSH");
 
 //Super Admin Specific calls
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/1f0c64f1/app/views/admin/manage-credentials.blade.php
----------------------------------------------------------------------
diff --git a/app/views/admin/manage-credentials.blade.php b/app/views/admin/manage-credentials.blade.php
index d0fe27a..eacd67c 100644
--- a/app/views/admin/manage-credentials.blade.php
+++ b/app/views/admin/manage-credentials.blade.php
@@ -44,6 +44,7 @@
                             Token
                         </th>
                         <th class="text-center">Public Key</th>
+                        <th>Delete</th>
                     </tr>
                     <tbody class="token-values">
                     @foreach( $tokens as $token => $publicKey)
@@ -54,6 +55,9 @@
                         <td class="public-key">
                             {{ $publicKey }}
                         </td>
+                        <td>
+                            <span data-token="{{$token}}" class="glyphicon glyphicon-trash
remove-token"></span>
+                        </td>
                     </tr>
                     @endforeach
                     </tbody>
@@ -140,6 +144,30 @@
 </div>
 
 
+<!-- Remove a Compute Resource from a Gateway -->
+<div class="modal fade" id="remove-token-block" tabindex="-1" role="dialog" aria-labelledby="add-modal"
+     aria-hidden="true">
+    <div class="modal-dialog">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h3 class="text-center">Remove SSH Key Confirmation</h3>
+            </div>
+            <div class="modal-body">
+                <input type="hidden" class="form-control remove-crId" name="rem-crId"/>
+                <input type="hidden" class="form-control cr-gpId" name="gpId"/>
+
+                Are you sure, you want to remove the SSH Key?<span class="remove-token-name">
</span>
+            </div>
+            <div class="modal-footer">
+                <div class="form-group">
+                    <input type="submit" class="btn btn-danger" value="Remove"/>
+                    <input type="button" class="btn btn-default" data-dismiss="modal"
value="Cancel"/>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+
 @stop
 
 @section('scripts')
@@ -149,7 +177,7 @@
         $(".loading-img").removeClass("hide");
         $.ajax({
           type: "POST",
-          url: "{{URL::to('/')}}/create-ssh-token"
+          url: "{{URL::to('/')}}/admin/create-ssh-token"
         }).success( function( data){
 
             var tokenJson = data;
@@ -157,7 +185,7 @@
             //$(".token-values").html("");
             $(".generate-ssh").after("<div class='alert alert-success new-token-msg'>New
Token has been generated.</div>");
 
-            $(".token-values").prepend("<tr class='alert alert-success'><td>"
+ tokenJson.token + "</td><td class='public-key'>" + tokenJson.pubkey + "</td></<tr>");
+            $(".token-values").prepend("<tr class='alert alert-success'><td>"
+ tokenJson.token + "</td><td class='public-key'>" + tokenJson.pubkey + "</td>"
+ "<td><a href=''><span data-token='"+tokenJson.token+"' class='glyphicon glyphicon-trash
remove-token'></span></a></td></<tr>");
             $(".loading-img").addClass("hide");
             
             setInterval( function(){
@@ -170,5 +198,24 @@
             $(".generate-ssh").after("<div class='alert alert-danger'>" + failureObject.error.message
+ "</div>");
         });
    });
+
+   $(".remove-token").click( function(){
+        var removeSpan = $(this);
+        var tokenToRemove = removeSpan.data("token");
+        $(".loading-img").removeClass("hide");
+        $.ajax({
+          type: "POST",
+          data:{ "token" : tokenToRemove},
+          url: "{{URL::to('/')}}/admin/remove-ssh-token"
+          }).success( function( data){
+            if( data.responseText == 1)
+                removeSpan.parent().parent().addClass("alert").addClass("alert-danger");
+                setTimeout( function(){
+                    removeSpan.parent().parent().slideUp(1000);
+                }, 2000);
+        }).fail( function( data){
+            removeSpan.parent().parent().after("<tr class='alert alert-danger'><td></td><td>Error
occurred : " + $.parseJSON( data.responseText).error.message + "</td><td></td></tr>");
+        });
+   });
 </script>
 @stop
\ No newline at end of file


Mime
View raw message