You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2017/09/25 21:11:02 UTC
[08/12] airavata-php-gateway git commit: AIRAVATA-2500 Prevent
deleting in-use user credentials
AIRAVATA-2500 Prevent deleting in-use user credentials
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/277f3468
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/277f3468
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/277f3468
Branch: refs/heads/AIRAVATA-2500
Commit: 277f34685da4273b1ee2f030b02c2830f6ca55e9
Parents: 2782a49
Author: Marcus Christie <ma...@iu.edu>
Authored: Thu Sep 7 16:31:28 2017 -0400
Committer: Marcus Christie <ma...@iu.edu>
Committed: Thu Sep 7 16:31:28 2017 -0400
----------------------------------------------------------------------
app/controllers/UserSettingsController.php | 22 +++++++++++++++++++++-
app/views/account/credential-store.blade.php | 11 +++++------
2 files changed, 26 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/277f3468/app/controllers/UserSettingsController.php
----------------------------------------------------------------------
diff --git a/app/controllers/UserSettingsController.php b/app/controllers/UserSettingsController.php
index d73e874..7f449a6 100644
--- a/app/controllers/UserSettingsController.php
+++ b/app/controllers/UserSettingsController.php
@@ -17,7 +17,7 @@ class UserSettingsController extends BaseController
$userCredentialSummaries = URPUtilities::get_all_ssh_pub_keys_summary_for_user();
$defaultCredentialToken = $userResourceProfile->credentialStoreToken;
foreach ($userCredentialSummaries as $credentialSummary) {
- $credentialSummary->canDelete = ($credentialSummary->token != $defaultCredentialToken);
+ $credentialSummary->canDelete = $this->canDeleteCredential($credentialSummary->token, $userResourceProfile);
}
return View::make("account/credential-store", array(
@@ -27,6 +27,26 @@ class UserSettingsController extends BaseController
));
}
+ // Don't allow deleting credential if default credential or in use by a
+ // userComputeResourcePreference or a userStoragePreference
+ private function canDeleteCredential($token, $userResourceProfile) {
+ if ($token == $userResourceProfile->credentialStoreToken) {
+ return false;
+ } else {
+ foreach ($userResourceProfile->userComputeResourcePreferences as $userCompResPref) {
+ if ($userCompResPref->resourceSpecificCredentialStoreToken == $token) {
+ return false;
+ }
+ }
+ foreach ($userResourceProfile->userStoragePreferences as $userStoragePreference) {
+ if ($userStoragePreference->resourceSpecificCredentialStoreToken == $token) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
public function setDefaultCredential() {
$defaultToken = Input::get("defaultToken");
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/277f3468/app/views/account/credential-store.blade.php
----------------------------------------------------------------------
diff --git a/app/views/account/credential-store.blade.php b/app/views/account/credential-store.blade.php
index a6b0b33..32e0f0d 100644
--- a/app/views/account/credential-store.blade.php
+++ b/app/views/account/credential-store.blade.php
@@ -57,15 +57,14 @@
@if ($credentialSummary->token != $defaultCredentialToken)
<form style="display: inline" action="{{ URL::to('/') }}/account/set-default-credential" method="post">
<input type="hidden" name="defaultToken" value="{{$credentialSummary->token}}"/>
- <button type="submit" class="btn btn-default">Make Default</button>
+ <button type="submit" class="btn btn-default" title="Test">Make Default</button>
</form>
- @else
- <small>This is the default SSH public key that the gateway will use to authenticate to your compute and storage accounts.</small>
- @endif
- @if ($credentialSummary->canDelete)
<button data-token="{{$credentialSummary->token}}"
data-description="{{$credentialSummary->description}}"
- class="btn btn-danger delete-credential">Delete</button>
+ class="btn btn-danger delete-credential"
+ @if(!$credentialSummary->canDelete) disabled @endif>Delete</button>
+ @else
+ <small>This is the default SSH public key that the gateway will use to authenticate to your compute and storage accounts.</small>
@endif
</div>
</div><!-- .row -->