X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Faccountview.py;h=5447bce8230dbb2d9cc4596ee42e7816be9ac066;hb=ebeba293279784d5281c8a13bdf2dae9cf4aed37;hp=2057f24178cd08b23375cea277394ae73d67f121;hpb=556bd356832001a26516da82eda588a023febe1e;p=unfold.git
diff --git a/portal/accountview.py b/portal/accountview.py
index 2057f241..5447bce8 100644
--- a/portal/accountview.py
+++ b/portal/accountview.py
@@ -2,7 +2,7 @@ from unfold.loginrequired import LoginRequiredAutoLogoutView
#
from manifold.core.query import Query
from manifold.manifoldapi import execute_query
-from portal.actions import manifold_update_user, manifold_update_account, manifold_add_account, manifold_delete_account
+from portal.actions import manifold_update_user, manifold_update_account, manifold_add_account, manifold_delete_account, sfa_update_user
#
from unfold.page import Page
from ui.topmenu import topmenu_items_live, the_user
@@ -86,43 +86,44 @@ class AccountView(LoginRequiredAutoLogoutView):
account_pub_key = account_config.get('user_public_key','N/A')
account_reference = account_config.get ('reference_platform','N/A')
# credentials
- acc_user_cred = account_config.get('delegated_user_credential','N/A')
- acc_slice_cred = account_config.get('delegated_slice_credentials','N/A')
- acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
+ if 'myslice' in platform_detail['platform']:
+ acc_user_cred = account_config.get('delegated_user_credential','N/A')
+ acc_slice_cred = account_config.get('delegated_slice_credentials','N/A')
+ acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
- if 'N/A' not in acc_user_cred:
- exp_date = re.search('(.*)', acc_user_cred)
- if exp_date:
- user_exp_date = exp_date.group(1)
- user_cred_exp_list.append(user_exp_date)
+ if 'N/A' not in acc_user_cred:
+ exp_date = re.search('(.*)', acc_user_cred)
+ if exp_date:
+ user_exp_date = exp_date.group(1)
+ user_cred_exp_list.append(user_exp_date)
- my_users = [{'cred_exp': t[0]}
- for t in zip(user_cred_exp_list)]
+ my_users = [{'cred_exp': t[0]}
+ for t in zip(user_cred_exp_list)]
- if 'N/A' not in acc_slice_cred:
- for key, value in acc_slice_cred.iteritems():
- slice_list.append(key)
- # get cred_exp date
- exp_date = re.search('(.*)', value)
- if exp_date:
- exp_date = exp_date.group(1)
- slice_cred_exp_list.append(exp_date)
+ if 'N/A' not in acc_slice_cred:
+ for key, value in acc_slice_cred.iteritems():
+ slice_list.append(key)
+ # get cred_exp date
+ exp_date = re.search('(.*)', value)
+ if exp_date:
+ exp_date = exp_date.group(1)
+ slice_cred_exp_list.append(exp_date)
- my_slices = [{'slice_name': t[0], 'cred_exp': t[1]}
- for t in zip(slice_list, slice_cred_exp_list)]
+ my_slices = [{'slice_name': t[0], 'cred_exp': t[1]}
+ for t in zip(slice_list, slice_cred_exp_list)]
- if 'N/A' not in acc_auth_cred:
- for key, value in acc_auth_cred.iteritems():
- auth_list.append(key)
- #get cred_exp date
- exp_date = re.search('(.*)', value)
- if exp_date:
- exp_date = exp_date.group(1)
- auth_cred_exp_list.append(exp_date)
+ if 'N/A' not in acc_auth_cred:
+ for key, value in acc_auth_cred.iteritems():
+ auth_list.append(key)
+ #get cred_exp date
+ exp_date = re.search('(.*)', value)
+ if exp_date:
+ exp_date = exp_date.group(1)
+ auth_cred_exp_list.append(exp_date)
- my_auths = [{'auth_name': t[0], 'cred_exp': t[1]}
- for t in zip(auth_list, auth_cred_exp_list)]
+ my_auths = [{'auth_name': t[0], 'cred_exp': t[1]}
+ for t in zip(auth_list, auth_cred_exp_list)]
# for reference accounts
@@ -321,10 +322,14 @@ def account_process(request):
user_hrn = account_config.get('user_hrn','N/A')
keypair = '{"user_public_key":'+ public_key + ', "user_private_key":'+ private_key + ', "user_hrn":"'+ user_hrn + '"}'
updated_config = json.dumps(account_config)
-
+ # updating manifold
user_params = { 'config': keypair, 'auth_type':'managed'}
manifold_update_account(request,user_params)
- messages.success(request, 'Sucess: New Keypair Generated!')
+ # updating sfa
+ public_key = public_key.replace('"', '');
+ user_pub_key = {'keys': public_key}
+ sfa_update_user(request, user_hrn, user_pub_key)
+ messages.success(request, 'Sucess: New Keypair Generated! Delegation of your credentials will be automatic.')
return HttpResponseRedirect("/portal/account/")
else:
messages.error(request, 'Account error: You need an account in myslice platform to perform this action')
@@ -409,6 +414,7 @@ def account_process(request):
user_params = { 'config': updated_config, 'auth_type':'user'}
manifold_update_account(request,user_params)
messages.success(request, 'Private Key deleted. You need to delegate credentials manually once it expires.')
+ messages.success(request, 'Once your credentials expire, Please delegate manually using SFA: http://trac.myslice.info/wiki/DelegatingCredentials')
return HttpResponseRedirect("/portal/account/")
else:
messages.error(request, 'Delete error: Private key is not stored in the server')
@@ -428,10 +434,9 @@ def account_process(request):
user_cred = account_config.get('delegated_user_credential','N/A')
if 'N/A' not in user_cred:
user_hrn = account_config.get('user_hrn','N/A')
- user_pub_key = account_config.get('user_public_key','N/A')
- user_priv_key = account_config.get('user_private_key','N/A')
- updated_config = '{"user_public_key":"'+ user_pub_key + '", "user_private_key":"'+ user_priv_key + '", "user_hrn":"'+ user_hrn + '"}'
- updated_config = ''.join(updated_config.split())
+ user_pub_key = json.dumps(account_config.get('user_public_key','N/A'))
+ user_priv_key = json.dumps(account_config.get('user_private_key','N/A'))
+ updated_config = '{"user_public_key":'+ user_pub_key + ', "user_private_key":'+ user_priv_key + ', "user_hrn":"'+ user_hrn + '"}'
user_params = { 'config': updated_config}
manifold_update_account(request,user_params)
messages.success(request, 'All Credentials cleared')