From: Jordan Augé Date: Thu, 24 Jul 2014 21:12:21 +0000 (+0200) Subject: Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab X-Git-Tag: myslice-1.0~45^2^2~2 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=87d78646979a54137f613f94b080014af7ab8f66;hp=1a17fe1834728dff6210388a9bda42dd20469242;p=myslice.git Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab --- diff --git a/plugins/testbeds/templates/testbeds.html b/plugins/testbeds/templates/testbeds.html index d670c9db..22f7f0ac 100644 --- a/plugins/testbeds/templates/testbeds.html +++ b/plugins/testbeds/templates/testbeds.html @@ -14,4 +14,11 @@ + + diff --git a/portal/accountview.py b/portal/accountview.py index c179a0e5..fb9f6427 100644 --- a/portal/accountview.py +++ b/portal/accountview.py @@ -348,6 +348,8 @@ def account_process(request): return HttpResponseRedirect("/portal/account/") # XXX TODO: Factorize with portal/registrationview.py +# XXX TODO: Factorize with portal/registrationview.py +# XXX TODO: Factorize with portal/joinview.py elif 'generate' in request.POST: for account_detail in account_details: diff --git a/portal/actions.py b/portal/actions.py index 3479c02b..d62f9941 100644 --- a/portal/actions.py +++ b/portal/actions.py @@ -321,13 +321,14 @@ def portal_validate_request(wsgi_request, request_ids): # XXX tmp sfa dependency from sfa.util.xrn import Xrn urn = Xrn(hrn, request['type']).get_urn() - + + # Only hrn is required for Manifold Query sfa_authority_params = { - 'hrn' : hrn, - 'urn' : urn, - 'type' : request['type'], + 'authority_hrn' : hrn, + #'authority_urn' : urn, + #'type' : request['type'], #'pi' : None, - 'enabled' : True + #'enabled' : True } print "ADD Authority" sfa_add_authority(wsgi_request, sfa_authority_params) @@ -376,6 +377,8 @@ def create_slice(wsgi_request, request): # Add User to Slice if we have the user_hrn in pendingslice table user_hrn = request.get('user_hrn', None) user_hrns = list([user_hrn]) if user_hrn else list() + + user_email = request.get # XXX We should create a slice with Manifold terminology slice_params = { @@ -391,6 +394,13 @@ def create_slice(wsgi_request, request): results = execute_query(wsgi_request, query) if not results: raise Exception, "Could not create %s. Already exists ?" % slice_params['hrn'] + ## We do not store the email in pendingslice table. As a result receiver's email is unknown ## + ## Need modification in pendingslice table ### + #else: + # subject = 'Slice created' + # msg = 'A manager of your institution has validated your slice request. You can now add resources to the slice and start experimenting.' + # send_mail(subject, msg, 'support@onelab.eu',['yasin.upmc@gmail.com'], fail_silently=False) + return results def create_pending_slice(wsgi_request, request, email): @@ -505,6 +515,10 @@ def sfa_create_user(wsgi_request, request): results = execute_query(wsgi_request, query) if not results: raise Exception, "Could not create %s. Already exists ?" % sfa_user_params['user_hrn'] + else: + subject = 'User validated' + msg = 'A manager of your institution has validated your account. You have now full user access to the portal.' + send_mail(subject, msg, 'support@onelab.eu',[request['email']], fail_silently=False) return results def create_user(wsgi_request, request): diff --git a/portal/joinview.py b/portal/joinview.py index 8356dec7..f9eed280 100644 --- a/portal/joinview.py +++ b/portal/joinview.py @@ -74,6 +74,8 @@ class JoinView (FreeAccessView, ThemeView): #prepare user_hrn split_email = reg_email.split("@")[0] split_email = split_email.replace(".", "_") + # Replace + by _ => more convenient for testing and validate with a real email + split_email = split_email.replace("+", "_") user_hrn = reg_auth + '.' + split_email UserModel = get_user_model() @@ -108,18 +110,15 @@ class JoinView (FreeAccessView, ThemeView): errors.append('Email already registered in Manifold. Please provide a new email address.') # XXX TODO: Factorize with portal/accountview.py +# XXX TODO: Factorize with portal/registrationview.py +# XXX TODO: Factorize with portal/joinview.py # if 'generate' in request.POST['question']: from Crypto.PublicKey import RSA private = RSA.generate(1024) - private_key = json.dumps(private.exportKey()) - public = private.publickey() - public_key = json.dumps(public.exportKey(format='OpenSSH')) - + private_key = private.exportKey() + public_key = private.publickey().exportKey(format='OpenSSH') # Saving to DB - account_config = '{"user_public_key":'+ public_key + ', "user_private_key":'+ private_key + ', "user_hrn":"'+ user_hrn + '"}' auth_type = 'managed' - public_key = public_key.replace('"', ''); - private_key = private_key.replace('"', ''); if not errors: reg_password = request.POST['pi_password'] diff --git a/portal/registrationview.py b/portal/registrationview.py index b996e95a..e0a1ddf3 100644 --- a/portal/registrationview.py +++ b/portal/registrationview.py @@ -85,6 +85,8 @@ class RegistrationView (FreeAccessView, ThemeView): # Construct user_hrn from email (XXX Should use common code) split_email = user_request['email'].split("@")[0] split_email = split_email.replace(".", "_") + # Replace + by _ => more convenient for testing and validate with a real email + split_email = split_email.replace("+", "_") user_request['user_hrn'] = user_request['authority_hrn'] \ + '.' + split_email @@ -120,6 +122,8 @@ class RegistrationView (FreeAccessView, ThemeView): + '.' + split_email + str(randint(1,1000000)) # XXX TODO: Factorize with portal/accountview.py + # XXX TODO: Factorize with portal/registrationview.py + # XXX TODO: Factorize with portal/joinview.py if 'generate' in wsgi_request.POST['question']: user_request['auth_type'] = 'managed' diff --git a/portal/slicerequestview.py b/portal/slicerequestview.py index 598aca39..95d2794b 100644 --- a/portal/slicerequestview.py +++ b/portal/slicerequestview.py @@ -35,6 +35,7 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView): purpose='' exp_url='' authority_hrn = None + authority_name = None # Retrieve the list of authorities authorities_query = Query.get('authority').select('name', 'authority_hrn') authorities = execute_admin_query(wsgi_request, authorities_query) @@ -54,6 +55,9 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView): if authority['authority_hrn'] == user_authority: authority_name = authority['name'] + # Handle the case when we use only hrn and not name + if authority_name is None: + authority_name = user_authority # account_query = Query().get('local:account').select('user_id','platform_id','auth_type','config') account_details = execute_query(wsgi_request, account_query) @@ -98,7 +102,7 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView): if authority['name'] == wsgi_request.POST.get('org_name', ''): authority_hrn = authority['authority_hrn'] - # Handle the case when the template uses only hrn and not name + # Handle the case when we use only hrn and not name if authority_hrn is None: authority_hrn = wsgi_request.POST.get('org_name', '')