Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[raz] Support creating a key by encoding headers
  • Loading branch information
romainr committed Jun 8, 2021
1 parent d2a8172 commit ee8212f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions desktop/core/src/desktop/lib/raz/clients.py
Expand Up @@ -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:
{
Expand All @@ -51,7 +51,7 @@ def get_url(self, action='GET', path=None, perm='read'):
service='s3',
)

return c.check_access(method=action, url=path)
return c.check_access(method=action, url=path, headers=headers)


class AdlsRazClient():
Expand Down
2 changes: 1 addition & 1 deletion desktop/core/src/desktop/lib/raz/raz_client.py
Expand Up @@ -92,7 +92,7 @@ def check_access(self, method, url, params=None, headers=None):

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("/")

Expand Down
6 changes: 3 additions & 3 deletions desktop/libs/aws/src/aws/s3/s3connection.py
Expand Up @@ -127,7 +127,7 @@ def make_request(self, method, bucket='', key='', headers=None, data='',

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:
Expand All @@ -141,10 +141,10 @@ def make_request(self, method, bucket='', key='', headers=None, data='',
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):
Expand Down

0 comments on commit ee8212f

Please sign in to comment.