diff --git a/Makefile b/Makefile index 10b435193..29d59ee61 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ check: @which pylint >/dev/null || pip install --user --upgrade pylint - @if python --version | grep -qi 'python 3'; then pylint --reports=no minio/copy_conditions.py minio/definitions.py; fi + @if python --version | grep -qi 'python 3'; then pylint --reports=no minio/copy_conditions.py minio/definitions.py minio/signer.py; fi @which isort >/dev/null || pip install --user --upgrade isort @isort --diff --recursive . diff --git a/minio/signer.py b/minio/signer.py index 9634e9524..b7f483371 100644 --- a/minio/signer.py +++ b/minio/signer.py @@ -103,15 +103,19 @@ def presign_v4(method, url, credentials, parsed_url = urlsplit(url) host = remove_default_port(parsed_url) headers['Host'] = host - iso8601Date = request_date.strftime("%Y%m%dT%H%M%SZ") + iso8601_date = request_date.strftime("%Y%m%dT%H%M%SZ") headers_to_sign = headers # Construct queries. query = {} query['X-Amz-Algorithm'] = _SIGN_V4_ALGORITHM query['X-Amz-Credential'] = generate_credential_string( - credentials.get().access_key, request_date, region, _PRESIGNED_SERVICE_NAME) - query['X-Amz-Date'] = iso8601Date + credentials.get().access_key, + request_date, + region, + _PRESIGNED_SERVICE_NAME, + ) + query['X-Amz-Date'] = iso8601_date query['X-Amz-Expires'] = str(expires) if credentials.get().session_token: query['X-Amz-Security-Token'] = credentials.get().session_token @@ -263,7 +267,8 @@ def generate_canonical_request(method, parsed_url, headers, signed_headers, return '\n'.join(lines) -def generate_string_to_sign(date, region, canonical_request, service_name=_DEFAULT_SERVICE_NAME): +def generate_string_to_sign(date, region, canonical_request, + service_name=_DEFAULT_SERVICE_NAME): """ Generate string to sign. @@ -285,7 +290,8 @@ def generate_string_to_sign(date, region, canonical_request, service_name=_DEFAU canonical_request_sha256]) -def generate_signing_key(date, region, secret_key, service_name=_DEFAULT_SERVICE_NAME): +def generate_signing_key(date, region, secret_key, + service_name=_DEFAULT_SERVICE_NAME): """ Generate signing key. @@ -324,7 +330,8 @@ def generate_scope_string(date, region, service_name): return scope -def generate_credential_string(access_key, date, region, service_name=_DEFAULT_SERVICE_NAME): +def generate_credential_string(access_key, date, region, + service_name=_DEFAULT_SERVICE_NAME): """ Generate credential string. @@ -359,6 +366,7 @@ def generate_authorization_header(access_key, date, region, def remove_default_port(parsed_url): + """Remove default port in URL.""" default_ports = { 'http': 80, 'https': 443