Moved INITIAL_NO_AUTH_ACTION_COUNT to settings.

This commit is contained in:
acsbendi 2019-07-24 16:30:48 +02:00
parent 95799b99bc
commit 3dd2e3a1b8
2 changed files with 3 additions and 4 deletions

View File

@ -1,6 +1,5 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import os
from collections import defaultdict from collections import defaultdict
import datetime import datetime
import json import json
@ -25,7 +24,7 @@ from werkzeug.exceptions import HTTPException
import boto3 import boto3
from moto.compat import OrderedDict from moto.compat import OrderedDict
from moto.core.utils import camelcase_to_underscores, method_names_from_class from moto.core.utils import camelcase_to_underscores, method_names_from_class
from moto.settings import INITIAL_NO_AUTH_ACTION_COUNT
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -108,11 +107,10 @@ class _TemplateEnvironmentMixin(object):
class ActionAuthenticatorMixin(object): class ActionAuthenticatorMixin(object):
INITIAL_NO_AUTH_ACTION_COUNT = float(os.environ.get("INITIAL_NO_AUTH_ACTION_COUNT", float("inf")))
request_count = 0 request_count = 0
def _authenticate_action(self, iam_request_cls): def _authenticate_action(self, iam_request_cls):
if ActionAuthenticatorMixin.request_count >= ActionAuthenticatorMixin.INITIAL_NO_AUTH_ACTION_COUNT: if ActionAuthenticatorMixin.request_count >= INITIAL_NO_AUTH_ACTION_COUNT:
iam_request = iam_request_cls(method=self.method, path=self.path, data=self.data, headers=self.headers) iam_request = iam_request_cls(method=self.method, path=self.path, data=self.data, headers=self.headers)
iam_request.check_signature() iam_request.check_signature()
iam_request.check_action_permitted() iam_request.check_action_permitted()

View File

@ -1,3 +1,4 @@
import os import os
TEST_SERVER_MODE = os.environ.get('TEST_SERVER_MODE', '0').lower() == 'true' TEST_SERVER_MODE = os.environ.get('TEST_SERVER_MODE', '0').lower() == 'true'
INITIAL_NO_AUTH_ACTION_COUNT = float(os.environ.get('INITIAL_NO_AUTH_ACTION_COUNT', float('inf')))