X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Fregistrationview.py;h=ba7370096a9ac11a6e59576fc4c20f3467143f58;hb=be1dd95ef614c4ae1793c17dcc7edb96c2a69e1a;hp=1f8ab8b85bfbd4580f88501597913bb929116931;hpb=fc73a99025ba9125c5d3aa2264179af0646e6568;p=unfold.git diff --git a/portal/registrationview.py b/portal/registrationview.py index 1f8ab8b8..ba737009 100644 --- a/portal/registrationview.py +++ b/portal/registrationview.py @@ -1,4 +1,5 @@ import os.path, re +import json from django.core.mail import send_mail @@ -33,10 +34,11 @@ class RegistrationView (View): select('name', 'authority_hrn') onelab_enabled_query = Query.get('local:platform').filter_by('platform', '==', 'ple-onelab').filter_by('disabled', '==', 'False') - onelab_enabled = not not execute_admin_query(request, onelab_enabled_query) + #onelab_enabled = not not execute_admin_query(request, onelab_enabled_query) + onelab_enabled = True if onelab_enabled: print "ONELAB ENABLED" - authorities_query = authorities_query.filter_by('authority_hrn', 'included', ['ple.inria', 'ple.upmc']) + authorities_query = authorities_query.filter_by('authority_hrn', 'included', ['ple.inria', 'ple.upmc', 'ple.ibbtple']) else: print "FIREXP ENABLED" @@ -68,16 +70,24 @@ class RegistrationView (View): # XXX validate authority hrn !! if PendingUser.objects.filter(email__iexact=reg_email): errors.append('Email already registered.Please provide a new email address.') + +# XXX TODO: Factorize with portal/accountview.py if 'generate' in request.POST['question']: - # Generate public and private keys using SFA Library - from sfa.trust.certificate import Keypair - k = Keypair(create=True) - public_key = k.get_pubkey_string() - private_key = k.as_pem() - private_key = ''.join(private_key.split()) - public_key = "ssh-rsa " + public_key + 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')) + +# # Generate public and private keys using SFA Library +# from sfa.trust.certificate import Keypair +# k = Keypair(create=True) +# public_key = k.get_pubkey_string() +# private_key = k.as_pem() +# private_key = ''.join(private_key.split()) +# public_key = "ssh-rsa " + public_key # Saving to DB - keypair = '{"user_public_key":"'+ public_key + '", "user_private_key":"'+ private_key + '"}' + keypair = '{"user_public_key":'+ public_key + ', "user_private_key":'+ private_key + '}' #keypair = re.sub("\r", "", keypair) #keypair = re.sub("\n", "\\n", keypair) #keypair = keypair.rstrip('\r\n')