瀏覽代碼

[raz] Support creating a key by encoding headers

Romain Rigaux 4 年之前
父節點
當前提交
ee8212f7a0

+ 2 - 2
desktop/core/src/desktop/lib/raz/clients.py

@@ -32,7 +32,7 @@ class S3RazClient():
   def __init__(self, username):
     self.username = username
 
-  def get_url(self, action='GET', path=None, perm='read'):
+  def get_url(self, action='GET', path=None, headers=None, perm='read'):
     '''
     Example of headers:
     {
@@ -51,7 +51,7 @@ class S3RazClient():
       service='s3',
     )
 
-    return c.check_access(method=action, url=path)
+    return c.check_access(method=action, url=path, headers=headers)
 
 
 class AdlsRazClient():

+ 1 - 1
desktop/core/src/desktop/lib/raz/raz_client.py

@@ -92,7 +92,7 @@ class RazClient(object):
 
     allparams = [raz_signer.StringListStringMapProto(key=key, value=[val]) for key, val in url_params.items()]
     allparams.extend([raz_signer.StringListStringMapProto(key=key, value=[val]) for key, val in params.items()])
-    headers = [raz_signer.StringStringMapProto(key=key, value=[val]) for key, val in headers.items()]
+    headers = [raz_signer.StringStringMapProto(key=key, value=val) for key, val in headers.items()]
     endpoint = "%s://%s" % (path.scheme, path.netloc)
     resource_path = path.path.lstrip("/")
 

+ 3 - 3
desktop/libs/aws/src/aws/s3/s3connection.py

@@ -127,7 +127,7 @@ class RazS3Connection(SignedUrlS3Connection):
 
     url = 'https://%(host)s%(path)s' % {'host': host, 'path': path}
 
-    headers = self.get_signed_url(action=method, url=url)
+    headers = self.get_signed_url(action=method, url=url, headers=headers)
     LOG.debug('Raz returned those headers: %s' % headers)
 
     if headers is not None:
@@ -141,10 +141,10 @@ class RazS3Connection(SignedUrlS3Connection):
                       retry_handler=retry_handler)
 
 
-  def get_signed_url(self, action='GET', url=None):
+  def get_signed_url(self, action='GET', url=None, headers=None):
     raz_client = S3RazClient(username=self.username)
 
-    return raz_client.get_url(action, url)
+    return raz_client.get_url(action, url, headers)
 
 
 class SelfSignedUrlS3Connection(SignedUrlS3Connection):