How to use the azure-cosmosdb-table.azure.cosmosdb.table.common.sharedaccesssignature._QueryStringConstants function in azure-cosmosdb-table

To help you get started, we’ve selected a few azure-cosmosdb-table examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / azure-cosmos-table-python / azure-cosmosdb-table / azure / cosmosdb / table / common / sharedaccesssignature.py View on Github external
# Form the string to sign from shared_access_policy and canonicalized
        # resource. The order of values is important.
        string_to_sign = \
            (get_value_to_append(_QueryStringConstants.SIGNED_PERMISSION) +
             get_value_to_append(_QueryStringConstants.SIGNED_START) +
             get_value_to_append(_QueryStringConstants.SIGNED_EXPIRY) +
             canonicalized_resource +
             get_value_to_append(_QueryStringConstants.SIGNED_IDENTIFIER) +
             get_value_to_append(_QueryStringConstants.SIGNED_IP) +
             get_value_to_append(_QueryStringConstants.SIGNED_PROTOCOL) +
             get_value_to_append(_QueryStringConstants.SIGNED_VERSION))

        if service == 'blob' or service == 'file':
            string_to_sign += \
                (get_value_to_append(_QueryStringConstants.SIGNED_CACHE_CONTROL) +
                 get_value_to_append(_QueryStringConstants.SIGNED_CONTENT_DISPOSITION) +
                 get_value_to_append(_QueryStringConstants.SIGNED_CONTENT_ENCODING) +
                 get_value_to_append(_QueryStringConstants.SIGNED_CONTENT_LANGUAGE) +
                 get_value_to_append(_QueryStringConstants.SIGNED_CONTENT_TYPE))

        # remove the trailing newline
        if string_to_sign[-1] == '\n':
            string_to_sign = string_to_sign[:-1]

        self._add_query(_QueryStringConstants.SIGNED_SIGNATURE,
                        _sign_string(account_key, string_to_sign))
github Azure / azure-cosmos-table-python / azure-cosmosdb-table / azure / cosmosdb / table / common / sharedaccesssignature.py View on Github external
def add_resource(self, resource):
        self._add_query(_QueryStringConstants.SIGNED_RESOURCE, resource)
github Azure / azure-cosmos-table-python / azure-cosmosdb-table / azure / cosmosdb / table / common / storageclient.py View on Github external
def _scrub_headers(headers):
        # make a copy to avoid contaminating the request
        clean_headers = headers.copy()

        if _AUTHORIZATION_HEADER_NAME in clean_headers:
            clean_headers[_AUTHORIZATION_HEADER_NAME] = _REDACTED_VALUE

        # in case of copy operations, there could be a SAS signature present in the header value
        if _COPY_SOURCE_HEADER_NAME in clean_headers \
                and _QueryStringConstants.SIGNED_SIGNATURE + "=" in clean_headers[_COPY_SOURCE_HEADER_NAME]:
            # take the url apart and scrub away the signed signature
            scheme, netloc, path, params, query, fragment = urlparse(clean_headers[_COPY_SOURCE_HEADER_NAME])
            parsed_qs = dict(parse_qsl(query))
            parsed_qs[_QueryStringConstants.SIGNED_SIGNATURE] = _REDACTED_VALUE

            # the SAS needs to be put back together
            clean_headers[_COPY_SOURCE_HEADER_NAME] = urlunparse(
                (scheme, netloc, path, params, urlencode(parsed_qs), fragment))
        return clean_headers
github Azure / azure-cosmos-table-python / azure-cosmosdb-table / azure / cosmosdb / table / common / sharedaccesssignature.py View on Github external
string_to_sign = \
            (get_value_to_append(_QueryStringConstants.SIGNED_PERMISSION) +
             get_value_to_append(_QueryStringConstants.SIGNED_START) +
             get_value_to_append(_QueryStringConstants.SIGNED_EXPIRY) +
             canonicalized_resource +
             get_value_to_append(_QueryStringConstants.SIGNED_IDENTIFIER) +
             get_value_to_append(_QueryStringConstants.SIGNED_IP) +
             get_value_to_append(_QueryStringConstants.SIGNED_PROTOCOL) +
             get_value_to_append(_QueryStringConstants.SIGNED_VERSION))

        if service == 'blob' or service == 'file':
            string_to_sign += \
                (get_value_to_append(_QueryStringConstants.SIGNED_CACHE_CONTROL) +
                 get_value_to_append(_QueryStringConstants.SIGNED_CONTENT_DISPOSITION) +
                 get_value_to_append(_QueryStringConstants.SIGNED_CONTENT_ENCODING) +
                 get_value_to_append(_QueryStringConstants.SIGNED_CONTENT_LANGUAGE) +
                 get_value_to_append(_QueryStringConstants.SIGNED_CONTENT_TYPE))

        # remove the trailing newline
        if string_to_sign[-1] == '\n':
            string_to_sign = string_to_sign[:-1]

        self._add_query(_QueryStringConstants.SIGNED_SIGNATURE,
                        _sign_string(account_key, string_to_sign))
github Azure / azure-cosmos-table-python / azure-cosmosdb-table / azure / cosmosdb / table / common / sharedaccesssignature.py View on Github external
(get_value_to_append(_QueryStringConstants.SIGNED_PERMISSION) +
             get_value_to_append(_QueryStringConstants.SIGNED_START) +
             get_value_to_append(_QueryStringConstants.SIGNED_EXPIRY) +
             canonicalized_resource +
             get_value_to_append(_QueryStringConstants.SIGNED_IDENTIFIER) +
             get_value_to_append(_QueryStringConstants.SIGNED_IP) +
             get_value_to_append(_QueryStringConstants.SIGNED_PROTOCOL) +
             get_value_to_append(_QueryStringConstants.SIGNED_VERSION))

        if service == 'blob' or service == 'file':
            string_to_sign += \
                (get_value_to_append(_QueryStringConstants.SIGNED_CACHE_CONTROL) +
                 get_value_to_append(_QueryStringConstants.SIGNED_CONTENT_DISPOSITION) +
                 get_value_to_append(_QueryStringConstants.SIGNED_CONTENT_ENCODING) +
                 get_value_to_append(_QueryStringConstants.SIGNED_CONTENT_LANGUAGE) +
                 get_value_to_append(_QueryStringConstants.SIGNED_CONTENT_TYPE))

        # remove the trailing newline
        if string_to_sign[-1] == '\n':
            string_to_sign = string_to_sign[:-1]

        self._add_query(_QueryStringConstants.SIGNED_SIGNATURE,
                        _sign_string(account_key, string_to_sign))
github Azure / azure-cosmos-table-python / azure-cosmosdb-table / azure / cosmosdb / table / common / sharedaccesssignature.py View on Github external
if path[0] != '/':
            path = '/' + path

        canonicalized_resource = '/' + service + '/' + account_name + path + '\n'

        # Form the string to sign from shared_access_policy and canonicalized
        # resource. The order of values is important.
        string_to_sign = \
            (get_value_to_append(_QueryStringConstants.SIGNED_PERMISSION) +
             get_value_to_append(_QueryStringConstants.SIGNED_START) +
             get_value_to_append(_QueryStringConstants.SIGNED_EXPIRY) +
             canonicalized_resource +
             get_value_to_append(_QueryStringConstants.SIGNED_IDENTIFIER) +
             get_value_to_append(_QueryStringConstants.SIGNED_IP) +
             get_value_to_append(_QueryStringConstants.SIGNED_PROTOCOL) +
             get_value_to_append(_QueryStringConstants.SIGNED_VERSION))

        if service == 'blob' or service == 'file':
            string_to_sign += \
                (get_value_to_append(_QueryStringConstants.SIGNED_CACHE_CONTROL) +
                 get_value_to_append(_QueryStringConstants.SIGNED_CONTENT_DISPOSITION) +
                 get_value_to_append(_QueryStringConstants.SIGNED_CONTENT_ENCODING) +
                 get_value_to_append(_QueryStringConstants.SIGNED_CONTENT_LANGUAGE) +
                 get_value_to_append(_QueryStringConstants.SIGNED_CONTENT_TYPE))

        # remove the trailing newline
        if string_to_sign[-1] == '\n':
            string_to_sign = string_to_sign[:-1]

        self._add_query(_QueryStringConstants.SIGNED_SIGNATURE,
                        _sign_string(account_key, string_to_sign))
github Azure / azure-cosmos-table-python / azure-cosmosdb-table / azure / cosmosdb / table / common / sharedaccesssignature.py View on Github external
def add_account_signature(self, account_name, account_key):
        def get_value_to_append(query):
            return_value = self.query_dict.get(query) or ''
            return return_value + '\n'

        string_to_sign = \
            (account_name + '\n' +
             get_value_to_append(_QueryStringConstants.SIGNED_PERMISSION) +
             get_value_to_append(_QueryStringConstants.SIGNED_SERVICES) +
             get_value_to_append(_QueryStringConstants.SIGNED_RESOURCE_TYPES) +
             get_value_to_append(_QueryStringConstants.SIGNED_START) +
             get_value_to_append(_QueryStringConstants.SIGNED_EXPIRY) +
             get_value_to_append(_QueryStringConstants.SIGNED_IP) +
             get_value_to_append(_QueryStringConstants.SIGNED_PROTOCOL) +
             get_value_to_append(_QueryStringConstants.SIGNED_VERSION))

        self._add_query(_QueryStringConstants.SIGNED_SIGNATURE,
                        _sign_string(account_key, string_to_sign))
github Azure / azure-cosmos-table-python / azure-cosmosdb-table / azure / cosmosdb / table / common / sharedaccesssignature.py View on Github external
def add_account(self, services, resource_types):
        self._add_query(_QueryStringConstants.SIGNED_SERVICES, services)
        self._add_query(_QueryStringConstants.SIGNED_RESOURCE_TYPES, resource_types)
github Azure / azure-cosmos-table-python / azure-cosmosdb-table / azure / cosmosdb / table / common / sharedaccesssignature.py View on Github external
def add_resource_signature(self, account_name, account_key, service, path):
        def get_value_to_append(query):
            return_value = self.query_dict.get(query) or ''
            return return_value + '\n'

        if path[0] != '/':
            path = '/' + path

        canonicalized_resource = '/' + service + '/' + account_name + path + '\n'

        # Form the string to sign from shared_access_policy and canonicalized
        # resource. The order of values is important.
        string_to_sign = \
            (get_value_to_append(_QueryStringConstants.SIGNED_PERMISSION) +
             get_value_to_append(_QueryStringConstants.SIGNED_START) +
             get_value_to_append(_QueryStringConstants.SIGNED_EXPIRY) +
             canonicalized_resource +
             get_value_to_append(_QueryStringConstants.SIGNED_IDENTIFIER) +
             get_value_to_append(_QueryStringConstants.SIGNED_IP) +
             get_value_to_append(_QueryStringConstants.SIGNED_PROTOCOL) +
             get_value_to_append(_QueryStringConstants.SIGNED_VERSION))

        if service == 'blob' or service == 'file':
            string_to_sign += \
                (get_value_to_append(_QueryStringConstants.SIGNED_CACHE_CONTROL) +
                 get_value_to_append(_QueryStringConstants.SIGNED_CONTENT_DISPOSITION) +
                 get_value_to_append(_QueryStringConstants.SIGNED_CONTENT_ENCODING) +
                 get_value_to_append(_QueryStringConstants.SIGNED_CONTENT_LANGUAGE) +
                 get_value_to_append(_QueryStringConstants.SIGNED_CONTENT_TYPE))

        # remove the trailing newline
        if string_to_sign[-1] == '\n':

azure-cosmosdb-table

Microsoft Azure CosmosDB Table Client Library for Python

Apache-2.0
Latest version published 5 years ago

Package Health Score

55 / 100
Full package analysis

Popular azure-cosmosdb-table functions

Similar packages