You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2016/06/25 05:00:34 UTC
airavata-php-gateway git commit: fixing AIRAVATA-1968, AIRAVATA-1969
Repository: airavata-php-gateway
Updated Branches:
refs/heads/develop e80f2a241 -> 6bceca048
fixing AIRAVATA-1968, AIRAVATA-1969
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/6bceca04
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/6bceca04
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/6bceca04
Branch: refs/heads/develop
Commit: 6bceca04813458a3e851b3223fe79ff4782d8bf5
Parents: e80f2a2
Author: scnakandala <su...@gmail.com>
Authored: Sat Jun 25 01:00:27 2016 -0400
Committer: scnakandala <su...@gmail.com>
Committed: Sat Jun 25 01:00:27 2016 -0400
----------------------------------------------------------------------
app/controllers/AdminController.php | 20 +++-
app/controllers/GatewayprofileController.php | 12 +++
app/libraries/AdminUtilities.php | 68 +++++++-----
app/libraries/Airavata/API/Airavata.php | 33 +++++-
app/routes.php | 6 ++
app/views/admin/manage-credentials.blade.php | 108 ++++++++++++++++++-
.../gateway-preferences-block.blade.php | 39 +++++--
7 files changed, 247 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6bceca04/app/controllers/AdminController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php
index c9f8d0d..6825483 100644
--- a/app/controllers/AdminController.php
+++ b/app/controllers/AdminController.php
@@ -60,7 +60,7 @@ class AdminController extends BaseController {
$gatewaysInfo = CRUtilities::getAllGatewayProfilesData();
$gateways = $gatewaysInfo["gateways"];
$tokens = AdminUtilities::get_all_ssh_tokens();
-
+ $pwdTokens = AdminUtilities::get_all_pwd_tokens();
$srData = SRUtilities::getEditSRData();
$crData = CRUtilities::getEditCRData();
@@ -85,6 +85,7 @@ class AdminController extends BaseController {
"storageResources" => $gatewaysInfo["allSRs"],
"srData" => $srData,
"tokens" => $tokens,
+ "pwdTokens" => $pwdTokens,
"unselectedCRs" => $unselectedCRs,
"unselectedSRs" => $unselectedSRs
);
@@ -179,8 +180,9 @@ class AdminController extends BaseController {
public function credentialStoreView(){
Session::put("admin-nav", "credential-store");
$tokens = AdminUtilities::get_all_ssh_tokens();
+ $pwdTokens = AdminUtilities::get_all_pwd_tokens();
//var_dump( $tokens); exit;
- return View::make("admin/manage-credentials", array("tokens" => $tokens ) );
+ return View::make("admin/manage-credentials", array("tokens" => $tokens , "pwdTokens" => $pwdTokens) );
}
public function updateUserRoles(){
@@ -272,6 +274,11 @@ class AdminController extends BaseController {
}
+ public function createPWD(){
+ AdminUtilities::create_pwd_token(Input::all());
+ return $this->credentialStoreView();
+ }
+
public function removeSSH(){
$removeToken = Input::get("token");
if( AdminUtilities::remove_ssh_token( $removeToken) )
@@ -281,6 +288,15 @@ class AdminController extends BaseController {
}
+ public function removePWD(){
+ $removeToken = Input::get("token");
+ if( AdminUtilities::remove_pwd_token( $removeToken) )
+ return 1;
+ else
+ return 0;
+
+ }
+
public function getUsersWithRole( $role){
$users = WSIS::getUserlistOfRole( $role);
if( isset( $users->return))
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6bceca04/app/controllers/GatewayprofileController.php
----------------------------------------------------------------------
diff --git a/app/controllers/GatewayprofileController.php b/app/controllers/GatewayprofileController.php
index e981f0b..35b8b43 100644
--- a/app/controllers/GatewayprofileController.php
+++ b/app/controllers/GatewayprofileController.php
@@ -60,6 +60,18 @@ class GatewayprofileController extends BaseController {
}
}
+ public function modifyIDP()
+ {
+ if( AdminUtilities::add_or_update_IDP( Input::all()) )
+ {
+ if( Request::ajax()){
+ return 1;
+ }
+ else
+ return Redirect::to("admin/dashboard/gateway")->with("message","Identity Server Preference has been set.");
+ }
+ }
+
public function delete()
{
$error = false;
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6bceca04/app/libraries/AdminUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/AdminUtilities.php b/app/libraries/AdminUtilities.php
index 64dfbc2..edb095f 100644
--- a/app/libraries/AdminUtilities.php
+++ b/app/libraries/AdminUtilities.php
@@ -75,41 +75,36 @@ class AdminUtilities
}
public static function create_ssh_token(){
- try{
- return $newToken = Airavata::generateAndRegisterSSHKeys( Session::get('authz-token'), Session::get("gateway_id"), Session::get("username"));
- } 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>');
- }
+ return $newToken = Airavata::generateAndRegisterSSHKeys( Session::get('authz-token'), Session::get("gateway_id"), Session::get("username"));
+ }
+
+ public static function create_pwd_token($inputs){
+ $username = $inputs['username'];
+ $password = $inputs['password'];
+ $description = $inputs['description'];
+ return $newToken = Airavata::registerPwdCredential( Session::get('authz-token'), Session::get("gateway_id"),
+ Session::get("username"), $username, $password, $description);
+
}
public static function get_all_ssh_tokens(){
return Airavata::getAllGatewaySSHPubKeys( Session::get('authz-token'), Session::get("gateway_id") );
}
+ public static function get_all_pwd_tokens(){
+ return Airavata::getAllGatewayPWDCredentials( Session::get('authz-token'), Session::get("gateway_id") );
+ }
+
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>');
- }
+ return Airavata::deletePWDCredential( Session::get('authz-token'), $token, Session::get("gateway_id"));
+ }
+
+ public static function remove_pwd_token( $token){
+ return Airavata::deleteSSHPubKey( Session::get('authz-token'), $token, Session::get("gateway_id"));
}
public static function add_or_update_notice( $notifData, $update = false){
@@ -142,4 +137,29 @@ class AdminUtilities
public static function delete_notice( $notificationId){
return Airavata::deleteNotification( Session::get('authz-token'), Session::get("gateway_id"), $notificationId);
}
+
+ public static function add_or_update_IDP($inputs)
+ {
+ $gatewayId = $inputs['gatewayId'];
+ $identityServerTenant = $inputs['identityServerTenant'];
+ $identityServerPwdCredToken = $inputs['identityServerPwdCredToken'];
+
+ $gp = Airavata::getGatewayResourceProfile(Session::get('authz-token'), $gatewayId);
+ if(!empty($identityServerTenant)){
+ $gp->identityServerTenant = $identityServerTenant;
+ }else{
+ $gp->identityServerTenant = "";
+ }
+
+ if(!empty($identityServerPwdCredToken) and $identityServerPwdCredToken != 'DO-NOT-SET'){
+ $gp->identityServerPwdCredToken = $identityServerPwdCredToken;
+ }else{
+ $gp->identityServerPwdCredToken = null;
+ }
+
+
+ Airavata::updateGatewayResourceProfile(Session::get('authz-token'), $gatewayId, $gp);
+
+ return true;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6bceca04/app/libraries/Airavata/API/Airavata.php
----------------------------------------------------------------------
diff --git a/app/libraries/Airavata/API/Airavata.php b/app/libraries/Airavata/API/Airavata.php
index a1de78d..8a3cc2c 100644
--- a/app/libraries/Airavata/API/Airavata.php
+++ b/app/libraries/Airavata/API/Airavata.php
@@ -272,12 +272,13 @@ interface AiravataIf {
* @param string $portalUserName
* @param string $loginUserName
* @param string $password
+ * @param string $description
* @return string
* @throws \Airavata\API\Error\InvalidRequestException
* @throws \Airavata\API\Error\AiravataClientException
* @throws \Airavata\API\Error\AiravataSystemException
*/
- public function registerPwdCredential(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId, $portalUserName, $loginUserName, $password);
+ public function registerPwdCredential(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId, $portalUserName, $loginUserName, $password, $description);
/**
* Get a Public Key by Providing the Token
*
@@ -4467,13 +4468,13 @@ class AiravataClient implements \Airavata\API\AiravataIf {
throw new \Exception("generateAndRegisterSSHKeys failed: unknown result");
}
- public function registerPwdCredential(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId, $portalUserName, $loginUserName, $password)
+ public function registerPwdCredential(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId, $portalUserName, $loginUserName, $password, $description)
{
- $this->send_registerPwdCredential($authzToken, $gatewayId, $portalUserName, $loginUserName, $password);
+ $this->send_registerPwdCredential($authzToken, $gatewayId, $portalUserName, $loginUserName, $password, $description);
return $this->recv_registerPwdCredential();
}
- public function send_registerPwdCredential(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId, $portalUserName, $loginUserName, $password)
+ public function send_registerPwdCredential(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId, $portalUserName, $loginUserName, $password, $description)
{
$args = new \Airavata\API\Airavata_registerPwdCredential_args();
$args->authzToken = $authzToken;
@@ -4481,6 +4482,7 @@ class AiravataClient implements \Airavata\API\AiravataIf {
$args->portalUserName = $portalUserName;
$args->loginUserName = $loginUserName;
$args->password = $password;
+ $args->description = $description;
$bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary');
if ($bin_accel)
{
@@ -17046,6 +17048,10 @@ class Airavata_registerPwdCredential_args {
* @var string
*/
public $password = null;
+ /**
+ * @var string
+ */
+ public $description = null;
public function __construct($vals=null) {
if (!isset(self::$_TSPEC)) {
@@ -17071,6 +17077,10 @@ class Airavata_registerPwdCredential_args {
'var' => 'password',
'type' => TType::STRING,
),
+ 6 => array(
+ 'var' => 'description',
+ 'type' => TType::STRING,
+ ),
);
}
if (is_array($vals)) {
@@ -17089,6 +17099,9 @@ class Airavata_registerPwdCredential_args {
if (isset($vals['password'])) {
$this->password = $vals['password'];
}
+ if (isset($vals['description'])) {
+ $this->description = $vals['description'];
+ }
}
}
@@ -17147,6 +17160,13 @@ class Airavata_registerPwdCredential_args {
$xfer += $input->skip($ftype);
}
break;
+ case 6:
+ if ($ftype == TType::STRING) {
+ $xfer += $input->readString($this->description);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
default:
$xfer += $input->skip($ftype);
break;
@@ -17188,6 +17208,11 @@ class Airavata_registerPwdCredential_args {
$xfer += $output->writeString($this->password);
$xfer += $output->writeFieldEnd();
}
+ if ($this->description !== null) {
+ $xfer += $output->writeFieldBegin('description', TType::STRING, 6);
+ $xfer += $output->writeString($this->description);
+ $xfer += $output->writeFieldEnd();
+ }
$xfer += $output->writeFieldStop();
$xfer += $output->writeStructEnd();
return $xfer;
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6bceca04/app/routes.php
----------------------------------------------------------------------
diff --git a/app/routes.php b/app/routes.php
index 9391d52..41fd139 100644
--- a/app/routes.php
+++ b/app/routes.php
@@ -217,6 +217,8 @@ Route::post("gp/add-srp", "GatewayprofileController@modifySRP");
Route::post("gp/update-srp", "GatewayprofileController@modifySRP");
+Route::post("gp/update-idp", "GatewayprofileController@modifyIDP");
+
Route::post("gp/remove-sr", "GatewayprofileController@delete");
Route::post("gp/credential-store-token-change", "GatewayprofileController@cstChange");
@@ -283,6 +285,10 @@ Route::post("admin/create-ssh-token", "AdminController@createSSH");
Route::post("admin/remove-ssh-token", "AdminController@removeSSH");
+Route::post("admin/create-pwd-token", "AdminController@createPWD");
+
+Route::post("admin/remove-pwd-token", "AdminController@removePWD");
+
//notices
Route::get("admin/dashboard/notices", "AdminController@noticesView");
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6bceca04/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 67196fb..b80553e 100644
--- a/app/views/admin/manage-credentials.blade.php
+++ b/app/views/admin/manage-credentials.blade.php
@@ -59,7 +59,7 @@
</td>
@if( Session::has("admin"))
<td>
- <span data-token="{{$token}}" class="glyphicon glyphicon-trash remove-token"></span>
+ <span data-token="{{$token}}" class="glyphicon glyphicon-trash remove=ssh-token"></span>
</td>
@endif
</tr>
@@ -105,7 +105,7 @@
<table class="table">
<tr class="text-center table-condensed">
<td>
- <button class="btn btn-default register-pwd-cred">Register a new password credential</button>
+ <button class="btn btn-default" data-toggle="modal" data-target="#pwd-cred-form">Register a new password credential</button>
</td>
</tr>
</table>
@@ -124,6 +124,21 @@
@endif
</tr>
<tbody class="token-values">
+ @foreach( $pwdTokens as $token => $publicKey)
+ <tr>
+ <td class="">
+ {{ $token }}
+ </td>
+ <td class="description">
+ {{ $publicKey }}
+ </td>
+ @if( Session::has("admin"))
+ <td>
+ <span data-token="{{$token}}" class="glyphicon glyphicon-trash remove-pwd-token"></span>
+ </td>
+ @endif
+ </tr>
+ @endforeach
</tbody>
</table>
@@ -146,6 +161,58 @@
</div>
</div>
</div>
+
+<div class="modal fade" id="pwd-cred-form" tabindex="-1" role="dialog" aria-hidden="true">
+ <div class="modal-dialog">
+ <div class="modal-content">
+ <!-- Modal Header -->
+ <div class="modal-header">
+ <button type="button" class="close"
+ data-dismiss="modal">
+ <span aria-hidden="true">×</span>
+ <span class="sr-only">Close</span>
+ </button>
+ <h4 class="modal-title">
+ Password Credential
+ </h4>
+ </div>
+
+ <!-- Modal Body -->
+ <div class="modal-body">
+
+ <form role="form" id="register-pwd-form" action="{{URL::to('/')}}/admin/create-pwd-token" method="POST">
+ <div class="form-group">
+ <label for="username">Username</label>
+ <input type="text" class="form-control" required="required"
+ id="username" name="username" placeholder="Username"/>
+ </div>
+ <div class="form-group">
+ <label for="password">Password</label>
+ <input type="text" class="form-control" required="required"
+ id="password" name="password" placeholder="Password"/>
+ </div>
+
+ <div class="form-group">
+ <label for="description">Description</label>
+ <input type="text" class="form-control" required="required"
+ id="description" name="description" placeholder="Description"/>
+ </div>
+
+ <!-- Modal Footer -->
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default"
+ data-dismiss="modal">
+ Close
+ </button>
+ <button type="submit" class="btn btn-primary">
+ Save changes
+ </button>
+ </div>
+ </form>
+ </div>
+ </div>
+ </div>
+</div>
@stop
@section('scripts')
@@ -177,7 +244,7 @@
});
});
- $(".remove-token").click( function(){
+ $(".remove-ssh-token").click( function(){
var removeSpan = $(this);
var tr = removeSpan.parent().parent();
var tokenToRemove = removeSpan.data("token");
@@ -211,5 +278,40 @@
});
});
+
+ $(".remove-pwd-token").click( function(){
+ var removeSpan = $(this);
+ var tr = removeSpan.parent().parent();
+ var tokenToRemove = removeSpan.data("token");
+ var description = tr.children(".description").html();
+ tr.children(".description").html("<div class='alert alert-danger'>Do you really want to remove the token? This action cannot be undone.<br/>" +
+ "<span class='btn-group'>"+
+ "<input type='button' class='btn btn-default remove-token-confirmation' value='Yes'/>" +
+ "<input type='button' class='btn btn-default remove-token-cancel' value='Cancel'/>"+
+ "</span></div>");
+
+
+ tr.find( ".remove-token-confirmation").click( function(){
+ $(".loading-img").removeClass("hide");
+ $.ajax({
+ type: "POST",
+ data:{ "token" : tokenToRemove},
+ url: "{{URL::to('/')}}/admin/remove-pwd-token"
+ }).success( function( data){
+ if( data.responseText == 1)
+ tr.addClass("alert").addClass("alert-danger");
+ tr.fadeOut(1000);
+ }).fail( function( data){
+ tr.after("<tr class='alert alert-danger'><td></td><td>Error occurred : " + $.parseJSON( data.responseText).error.message + "</td><td></td></tr>");
+ }).complete( function(){
+ $(".loading-img").addClass("hide");
+
+ });
+ });
+ tr.find( ".remove-token-cancel").click( function(){
+ tr.children(".description").html( description);
+ });
+
+ });
</script>
@stop
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6bceca04/app/views/partials/gateway-preferences-block.blade.php
----------------------------------------------------------------------
diff --git a/app/views/partials/gateway-preferences-block.blade.php b/app/views/partials/gateway-preferences-block.blade.php
index 1724605..e4ad635 100644
--- a/app/views/partials/gateway-preferences-block.blade.php
+++ b/app/views/partials/gateway-preferences-block.blade.php
@@ -188,12 +188,39 @@
<div>
<h3>Identity Server Configuration :</h3>
</div>
- <div>
- <label>Tenant ID :</label>
- <input type="text">
- </br>
- <label>Password Credential Token :</label>
- <input type="text">
+ <div class="panel panel-default panel-body">
+ <form action="{{URL::to('/')}}/gp/update-idp" method="POST">
+ <input type="hidden" name="gatewayId" id="gatewayId"
+ value="{{$gp->gatewayId}}">
+ <br/>
+ <div class="form-horizontal">
+ <div>
+ <div class="form-group">
+ <label class="control-label col-md-3">Tenant ID</label>
+ <div class="col-md-9">
+ <input type="text" name="identityServerTenant" class="form-control"
+ value="@if( isset( $gp->profile->identityServerTenant) ){{$gp->profile->identityServerTenant}}@endif"/>
+ </div>
+ </div>
+ <div class="form-group">
+ <label class="control-label col-md-3">Identity Server Password Credential</label>
+ <div class="col-md-9">
+ <select class="form-control gateway-credential-store-token" name="identityServerPwdCredToken">
+ @foreach( $pwdTokens as $token => $description)
+ <option value="{{$token}}" @if( isset( $gp->profile->identityServerPwdCredToken) ) @if( $token == $gp->profile->identityServerPwdCredToken) selected @endif @endif>{{$token}}</option>
+ @endforeach
+ <option value="">DO-NO-SET</option>
+ </select>
+ </div>
+ </div>
+ @if(Session::has("admin"))
+ <div class="form-group text-center">
+ <input type="submit" class="btn btn-primary submit-srp-form" value="Set preferences"/>
+ </div>
+ @endif
+ </div>
+ </div>
+ </form>
</div>
</div>