Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: canonical request path if empty choose '/' #1165

Merged
merged 1 commit into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion minio/credentials/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def __init__(
self._body = urlencode(query_params)
self._content_sha256 = sha256_hash(self._body)
url = urlsplit(sts_endpoint)
self._url = url
self._host = url.netloc
if (
(url.scheme == "http" and url.port == 80) or
Expand All @@ -131,7 +132,7 @@ def retrieve(self):
utctime = utcnow()
headers = sign_v4_sts(
"POST",
urlsplit(self._sts_endpoint),
self._url,
self._region,
{
"Content-Type": "application/x-www-form-urlencoded",
Expand Down
8 changes: 4 additions & 4 deletions minio/signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def _get_canonical_headers(headers):
for key, values in headers.items():
key = key.lower()
if key not in (
"authorization", "content-type",
"content-length", "user-agent",
"authorization",
"user-agent",
):
values = values if isinstance(values, (list, tuple)) else [values]
canonical_headers[key] = ",".join([
Expand Down Expand Up @@ -101,7 +101,7 @@ def _get_canonical_request_hash(method, url, headers, content_sha256):
# HexEncode(Hash(RequestPayload))
canonical_request = (
f"{method}\n"
f"{url.path}\n"
f"{url.path or '/'}\n"
f"{canonical_query_string}\n"
f"{canonical_headers}\n\n"
f"{signed_headers}\n"
Expand Down Expand Up @@ -248,7 +248,7 @@ def _get_presign_canonical_request_hash( # pylint: disable=invalid-name
# HexEncode(Hash(RequestPayload))
canonical_request = (
f"{method}\n"
f"{url.path}\n"
f"{url.path or '/'}\n"
f"{canonical_query_string}\n"
f"{canonical_headers}\n\n"
f"{signed_headers}\n"
Expand Down