Example #1
0
def create_user(email, private_key, **attrs):
    """
   Create a user.
   
   Requred positional arguments:
      email (str): 
         The email address of the new user.  It will
         serve as the user's identifier, so it must 
         be unique.
      
      private_key (str)
         The PEM-encoded private key that the MS will
         use to authenticate a client program that wishes
         to access this user.  The client program must use 
         the key to sign requests to the MS, in order to
         prove to the MS that the program is acting on
         behalf of the owner of this user account. 
         Currently, this must be a 4096-bit RSA key.
         
         Pass "auto" if you want Syndicate to automatically
         generate a key pair for you, in which case the private 
         key will be stored to your Syndicate key directory
         on successful return of this method.
         
   Optional keyword arguments:
      
      max_volumes=int: (default: 10)
         Maximum number of Volumes this user may own.
         -1 means infinite.
      
      max_gateways=int: (default: 10)
         Maximum number of gateways this user can own.
         
      is_admin=bool: (default: False)
         Whether or not this user will be a Syndicate admin.
      
         
   Returns:
      A SyndicateUser object on success, or an exception
      on error.
      
   Authorization:
      Only an administrator can create new users.
      
   Remarks:
      Syndicate will generate a protobuf'ed certificate and send it 
      as a keyword argument called 'user_cert_b64'.  It will contain 
      the new user's ID, email, and public key.
      
      Syndicate does *not* send the private key.  It stores it locally 
      instead.
   """

    return storage.create_user(email, **attrs)
Example #2
0
def create_user(email, private_key, **attrs):
    """
   Create a user.
   
   Requred positional arguments:
      email (str): 
         The email address of the new user.  It will
         serve as the user's identifier, so it must 
         be unique.
      
      private_key (str)
         The PEM-encoded private key that the MS will
         use to authenticate a client program that wishes
         to access this user.  The client program must use 
         the key to sign requests to the MS, in order to
         prove to the MS that the program is acting on
         behalf of the owner of this user account. 
         Currently, this must be a 4096-bit RSA key.
         
         Pass "auto" if you want Syndicate to automatically
         generate a key pair for you, in which case the private 
         key will be stored to your Syndicate key directory
         on successful return of this method.
         
   Optional keyword arguments:
      
      max_volumes=int: (default: 10)
         Maximum number of Volumes this user may own.
         -1 means infinite.
      
      max_gateways=int: (default: 10)
         Maximum number of gateways this user can own.
         
      is_admin=bool: (default: False)
         Whether or not this user will be a Syndicate admin.
      
         
   Returns:
      A SyndicateUser object on success, or an exception
      on error.
      
   Authorization:
      Only an administrator can create new users.
      
   Remarks:
      Syndicate will generate a protobuf'ed certificate and send it 
      as a keyword argument called 'user_cert_b64'.  It will contain 
      the new user's ID, email, and public key.
      
      Syndicate does *not* send the private key.  It stores it locally 
      instead.
   """

    return storage.create_user(email, **attrs)
Example #3
0
 def wrapper(*args, **kw):
     session = args[0].session
     if 'authenticated' in session:
         user = db.read_user(session['login_email'])
         if user:
             return f(*args, **kw)
         else:
             kwargs = {}
             kwargs['email'] = session['login_email']
             kwargs['openid_url'] = session['openid_url']
             user = db.create_user(**kwargs)
         session['user_key'] = user
         return f(*args, **kw)
     else:
         return redirect('/')