Skip to content

Commit

Permalink
fix pylint errors in signer.py (#917)
Browse files Browse the repository at this point in the history
  • Loading branch information
balamurugana authored May 7, 2020
1 parent 2bd0887 commit a0065ce
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
20 changes: 14 additions & 6 deletions minio/signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a0065ce

Please sign in to comment.