28 from common.utils
import ServerProxy
29 from ec2.base.action
import CLMException
30 from ec2.error
import AuthFailure, InvalidAccessKeyId
31 from ec2.settings
import CLM_ADDRESS, BUCKETS_PATH
33 CLM_AUTHENTICATE =
'/guest/user/check_signature/'
37 clm = ServerProxy(CLM_ADDRESS)
39 temp_input = parameters[
'input']
40 temp_file_wrapper = parameters[
'file_wrapper']
42 del parameters[
'input']
43 del parameters[
'file_wrapper']
45 data = {
'parameters': parameters}
46 response = clm.send_request(CLM_AUTHENTICATE, **data)
47 status = response[
'status']
54 parameters[
'input'] = temp_input
55 parameters[
'file_wrapper'] = temp_file_wrapper
57 user_name = parameters[
'authorization'].split(
' ')[1].split(
':')[0]
58 print 'Username:', user_name
59 if user_name.find(
'..') != -1:
60 raise InvalidAccessKeyId
62 bucket_path = os.path.join(BUCKETS_PATH, user_name)
63 print 'Bucket path:', bucket_path
65 if not os.path.exists(bucket_path):
66 print 'User\'s directory does not exists, creating'
69 print 'Authentication process successful'