Check S3_IGNORE_SUBDOMAIN_BUCKETNAME environment variable (#3796)
* Check S3_IGNORE_SUBDOMAIN_BUCKETNAME environment variable * move S3_IGNORE_SUBDOMAIN_BUCKETNAME environment variable to settings
This commit is contained in:
parent
1761be46e3
commit
9f9716ee01
6 changed files with 30 additions and 9 deletions
|
|
@ -27,6 +27,7 @@ from moto.packages.httpretty.core import HTTPrettyRequest
|
|||
from moto.core.responses import _TemplateEnvironmentMixin, ActionAuthenticatorMixin
|
||||
from moto.core.utils import path_url
|
||||
from moto.core import ACCOUNT_ID
|
||||
from moto.settings import S3_IGNORE_SUBDOMAIN_BUCKETNAME
|
||||
|
||||
from moto.s3bucket_path.utils import (
|
||||
bucket_name_from_url as bucketpath_bucket_name_from_url,
|
||||
|
|
@ -186,6 +187,8 @@ class ResponseObject(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):
|
|||
return template.render(buckets=all_buckets)
|
||||
|
||||
def subdomain_based_buckets(self, request):
|
||||
if S3_IGNORE_SUBDOMAIN_BUCKETNAME:
|
||||
return False
|
||||
host = request.headers.get("host", request.headers.get("Host"))
|
||||
if not host:
|
||||
host = urlparse(request.url).netloc
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
from __future__ import unicode_literals
|
||||
import logging
|
||||
import os
|
||||
|
||||
import re
|
||||
import six
|
||||
from six.moves.urllib.parse import urlparse, unquote, quote
|
||||
from requests.structures import CaseInsensitiveDict
|
||||
import sys
|
||||
from moto.settings import S3_IGNORE_SUBDOMAIN_BUCKETNAME
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
|
@ -26,7 +26,7 @@ user_settable_fields = {
|
|||
|
||||
|
||||
def bucket_name_from_url(url):
|
||||
if os.environ.get("S3_IGNORE_SUBDOMAIN_BUCKETNAME", "") in ["1", "true"]:
|
||||
if S3_IGNORE_SUBDOMAIN_BUCKETNAME:
|
||||
return None
|
||||
domain = urlparse(url).netloc
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue