From 15d7fa039a97e3586f849943aee202ea1bf6678f Mon Sep 17 00:00:00 2001 From: "Bala.FA" Date: Fri, 6 Dec 2024 17:18:56 +0530 Subject: [PATCH] IamAwsProvider: fix url with role name Fixes #1459 Signed-off-by: Bala.FA --- .github/workflows/ci.yml | 2 +- minio/credentials/providers.py | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e913729a..22963d98 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13.0"] os: [ubuntu-latest, windows-latest, macos-latest] steps: diff --git a/minio/credentials/providers.py b/minio/credentials/providers.py index 718d245a..53073fd0 100644 --- a/minio/credentials/providers.py +++ b/minio/credentials/providers.py @@ -505,21 +505,17 @@ def retrieve(self) -> Credentials: headers = {"X-aws-ec2-metadata-token": token} if token else None # Get role name - res = _urlopen( - self._http_client, - "GET", - urlunsplit( - url_replace( - urlsplit(url), - path="/latest/meta-data/iam/security-credentials/", - ), + url = urlunsplit( + url_replace( + urlsplit(url), + path="/latest/meta-data/iam/security-credentials/", ), - headers=headers, ) + res = _urlopen(self._http_client, "GET", url, headers=headers) role_names = res.data.decode("utf-8").split("\n") if not role_names: raise ValueError(f"no IAM roles attached to EC2 service {url}") - url += "/" + role_names[0].strip("\r") + url += role_names[0].strip("\r") if not url: raise ValueError("url is empty; this should not happen") self._credentials = self.fetch(url, headers=headers)