From bec0c5a273e14d66affbe1cebdefe54fc4f3574b Mon Sep 17 00:00:00 2001 From: acsbendi Date: Wed, 10 Jul 2019 20:42:23 +0200 Subject: [PATCH] Fixed S3 actions not handled properly. --- moto/core/authentication.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/moto/core/authentication.py b/moto/core/authentication.py index 54f33b73..523bd83f 100644 --- a/moto/core/authentication.py +++ b/moto/core/authentication.py @@ -1,5 +1,6 @@ import json import re +import sys from abc import ABC, abstractmethod from enum import Enum @@ -121,7 +122,7 @@ class CreateAccessKeyFailure(Exception): class IAMRequestBase(ABC): def __init__(self, method, path, data, headers): - print(f"Creating {self.__class__.__name__} with method={method}, path={path}, data={data}, headers={headers}") + print(f"Creating {self.__class__.__name__} with method={method}, path={path}, data={data}, headers={headers}", file=sys.stderr) self._method = method self._path = path self._data = data @@ -130,7 +131,7 @@ class IAMRequestBase(ABC): credential_data = credential_scope.split('/') self._region = credential_data[2] self._service = credential_data[3] - self._action = self._service + ":" + self._data["Action"][0] + self._action = self._service + ":" + (self._data["Action"][0] if isinstance(self._data["Action"], list) else self._data["Action"]) try: self._access_key = create_access_key(access_key_id=credential_data[0], headers=headers) except CreateAccessKeyFailure as e: @@ -143,9 +144,6 @@ class IAMRequestBase(ABC): raise SignatureDoesNotMatchError() def check_action_permitted(self): - self._check_action_permitted_for_iam_user() - - def _check_action_permitted_for_iam_user(self): policies = self._access_key.collect_policies() permitted = False