addons-server/settings.py

170 строки
5.3 KiB
Python
Исходник Обычный вид История

"""This is the standard development settings file.
If you need to overload settings, please do so in a local_settings.py file (it
won't be tracked in git).
"""
2014-10-01 15:44:44 +04:00
import os
from urllib.parse import urlparse
2014-10-01 15:44:44 +04:00
from olympia.lib.settings_base import * # noqa
WSGI_APPLICATION = 'olympia.wsgi.application'
INTERNAL_ROUTES_ALLOWED = True
DEBUG = True
# These apps are great during development.
INSTALLED_APPS += (
'olympia.landfill',
'debug_toolbar',
)
2020-05-19 17:54:15 +03:00
# Override logging config to enable DEBUG logs for (almost) everything.
LOGGING['root']['level'] = logging.DEBUG
for logger in list(LOGGING['loggers'].keys()):
if logger not in ['filtercascade', 'mohawk.util', 'post_request_task']:
2020-06-05 14:30:11 +03:00
# It is important to keep the loggers configured in `settings_base.py`
# so we only update the level below:
LOGGING['loggers'][logger]['level'] = logging.DEBUG
# django-debug-doolbar middleware needs to be inserted as high as possible
# but after GZip middleware
def insert_debug_toolbar_middleware(middlewares):
ret_middleware = list(middlewares)
for i, middleware in enumerate(ret_middleware):
if 'GZipMiddleware' in middleware:
ret_middleware.insert(
i + 1, 'debug_toolbar.middleware.DebugToolbarMiddleware'
)
break
return tuple(ret_middleware)
MIDDLEWARE = insert_debug_toolbar_middleware(MIDDLEWARE)
DEBUG_TOOLBAR_CONFIG = {
# Enable django-debug-toolbar locally, if DEBUG is True.
'SHOW_TOOLBAR_CALLBACK': lambda request: DEBUG,
}
FILESYSTEM_CACHE_ROOT = os.path.join(TMP_PATH, 'cache')
# If you're not running on SSL you'll want this to be False.
SESSION_COOKIE_SECURE = False
SESSION_COOKIE_DOMAIN = None
WAFFLE_SECURE = False
CELERY_TASK_ALWAYS_EAGER = False
# Locally we typically don't run more than 1 elasticsearch node. So we set
# replicas to zero.
ES_DEFAULT_NUM_REPLICAS = 0
SITE_URL = os.environ.get('OLYMPIA_SITE_URL') or 'http://localhost:8000'
DOMAIN = SERVICES_DOMAIN = urlparse(SITE_URL).netloc
ADDONS_FRONTEND_PROXY_PORT = '7000'
SERVICES_URL = SITE_URL
INTERNAL_SITE_URL = 'http://nginx'
EXTERNAL_SITE_URL = SITE_URL
STATIC_URL = '%s/static/' % EXTERNAL_SITE_URL
MEDIA_URL = '%s/user-media/' % EXTERNAL_SITE_URL
CODE_MANAGER_URL = os.environ.get('CODE_MANAGER_URL') or 'http://olympia.test:5000'
ALLOWED_HOSTS = ALLOWED_HOSTS + [SERVICES_DOMAIN, 'nginx']
# Default AMO user id to use for tasks (from users.json fixture in zadmin).
TASK_USER_ID = 10968
2018-04-09 17:48:02 +03:00
ALLOW_SELF_REVIEWS = True
AES_KEYS = {
'api_key:secret': os.path.join(
ROOT, 'src', 'olympia', 'api', 'tests', 'assets', 'test-api-key.txt'
),
}
DATABASES = {
'default': get_db_config('DATABASES_DEFAULT_URL'),
}
# FxA config for local development only.
FXA_CONFIG = {
2016-04-21 23:31:31 +03:00
'default': {
'client_id': env('FXA_CLIENT_ID', default='a25796da7bc73ffa'),
WIP: Cleanup locustio based performance / smoke tests, add more entities (#8358) * Port mozilla/amo-loadtest to FXA authentication and WebExtensions. This is the first part of many to improve our load-tests and allow them to be run regularly as part of a regression test suite. This commit primarily ports the existing tests over to our repository, updates them to use FxA authentication and uses a WebExtension for the upload test. This only implements the baseline for more work to come in #7744 but it's important to have authentication and the basic infrastructure working correctly. It's also still using the legacy add-on detail and listing pages, that'll obviously change - or be only true for SeaMonkey and Thunderbird related tests since we still have to support them (very low priority though) It also adds a first step of a summary report that links to new-relic. That'll need a bit more tooling and testing but it worked quite well in first tests. Refs #7744 Next steps: * Implement most of the read-only tests from #7744 * Check what needs auth in #7744, implement it properly * Implement database and cache query logging * Implement a unified merged test-report that uses the database and cache query logging and merges it with locust logs (using our new unique request id) * Fix makefile, show dummy-usage for now. * Delete generate-summary script for now * Pin and cleanup dependencies * Reverse all urls * Use passed in account for login * split things up * Use gevent for waiting, some cleanups, add first version of Dockerfile, running script, disable developer stuff for now * Add browsing collections and browsing categories * Add loads more variation, add support for thunderbird, seamonkey, multiple languages * Decrease size of docker images for local testing * Get installation and docker image mostly to work, docs, cleanups * Allow fxa environment variables be overwritten * Hit legacy site of every variation * More explicit theme testing * Add browsing for app-versions and various rss feeds * More variation in rss feeds, add featured and search tools * Add a few more response.success() calls * Test user profile pages, warn for empty collection pages * More docs * Add review browsing
2018-05-30 17:46:16 +03:00
'client_secret': env(
'FXA_CLIENT_SECRET',
default='4828af02f60a12738a79c7121b06d42b481f112dce1831440902a8412d2770c5',
),
# fxa redirects to http://olympia.test/api/auth/authenticate-callback/
2016-04-21 23:31:31 +03:00
},
2018-04-09 17:48:02 +03:00
'amo': {
WIP: Cleanup locustio based performance / smoke tests, add more entities (#8358) * Port mozilla/amo-loadtest to FXA authentication and WebExtensions. This is the first part of many to improve our load-tests and allow them to be run regularly as part of a regression test suite. This commit primarily ports the existing tests over to our repository, updates them to use FxA authentication and uses a WebExtension for the upload test. This only implements the baseline for more work to come in #7744 but it's important to have authentication and the basic infrastructure working correctly. It's also still using the legacy add-on detail and listing pages, that'll obviously change - or be only true for SeaMonkey and Thunderbird related tests since we still have to support them (very low priority though) It also adds a first step of a summary report that links to new-relic. That'll need a bit more tooling and testing but it worked quite well in first tests. Refs #7744 Next steps: * Implement most of the read-only tests from #7744 * Check what needs auth in #7744, implement it properly * Implement database and cache query logging * Implement a unified merged test-report that uses the database and cache query logging and merges it with locust logs (using our new unique request id) * Fix makefile, show dummy-usage for now. * Delete generate-summary script for now * Pin and cleanup dependencies * Reverse all urls * Use passed in account for login * split things up * Use gevent for waiting, some cleanups, add first version of Dockerfile, running script, disable developer stuff for now * Add browsing collections and browsing categories * Add loads more variation, add support for thunderbird, seamonkey, multiple languages * Decrease size of docker images for local testing * Get installation and docker image mostly to work, docs, cleanups * Allow fxa environment variables be overwritten * Hit legacy site of every variation * More explicit theme testing * Add browsing for app-versions and various rss feeds * More variation in rss feeds, add featured and search tools * Add a few more response.success() calls * Test user profile pages, warn for empty collection pages * More docs * Add review browsing
2018-05-30 17:46:16 +03:00
'client_id': env('FXA_CLIENT_ID', default='0f95f6474c24c1dc'),
'client_secret': env(
'FXA_CLIENT_SECRET',
default='ca45e503a1b4ec9e2a3d4855d79849e098da18b7dfe42b6bc76dfed420fc1d38',
),
# fxa redirects to http://localhost:3000/fxa-authenticate
2016-04-21 23:31:31 +03:00
},
'local': {
'client_id': env('FXA_CLIENT_ID', default='4dce1adfa7901c08'),
WIP: Cleanup locustio based performance / smoke tests, add more entities (#8358) * Port mozilla/amo-loadtest to FXA authentication and WebExtensions. This is the first part of many to improve our load-tests and allow them to be run regularly as part of a regression test suite. This commit primarily ports the existing tests over to our repository, updates them to use FxA authentication and uses a WebExtension for the upload test. This only implements the baseline for more work to come in #7744 but it's important to have authentication and the basic infrastructure working correctly. It's also still using the legacy add-on detail and listing pages, that'll obviously change - or be only true for SeaMonkey and Thunderbird related tests since we still have to support them (very low priority though) It also adds a first step of a summary report that links to new-relic. That'll need a bit more tooling and testing but it worked quite well in first tests. Refs #7744 Next steps: * Implement most of the read-only tests from #7744 * Check what needs auth in #7744, implement it properly * Implement database and cache query logging * Implement a unified merged test-report that uses the database and cache query logging and merges it with locust logs (using our new unique request id) * Fix makefile, show dummy-usage for now. * Delete generate-summary script for now * Pin and cleanup dependencies * Reverse all urls * Use passed in account for login * split things up * Use gevent for waiting, some cleanups, add first version of Dockerfile, running script, disable developer stuff for now * Add browsing collections and browsing categories * Add loads more variation, add support for thunderbird, seamonkey, multiple languages * Decrease size of docker images for local testing * Get installation and docker image mostly to work, docs, cleanups * Allow fxa environment variables be overwritten * Hit legacy site of every variation * More explicit theme testing * Add browsing for app-versions and various rss feeds * More variation in rss feeds, add featured and search tools * Add a few more response.success() calls * Test user profile pages, warn for empty collection pages * More docs * Add review browsing
2018-05-30 17:46:16 +03:00
'client_secret': env(
'FXA_CLIENT_SECRET',
default='d7d5f1148a35b12c067fb9eafafc29d35165a90f5d8b0032f1fcd37468ae49fe',
),
# fxa redirects to http://localhost:3000/api/auth/authenticate-callback/?config=local # noqa
},
}
FXA_CONTENT_HOST = 'https://stable.dev.lcip.org'
FXA_OAUTH_HOST = 'https://oauth-stable.dev.lcip.org/v1'
FXA_PROFILE_HOST = 'https://stable.dev.lcip.org/profile/v1'
ALLOWED_FXA_CONFIGS = ['default', 'amo', 'local']
# When USE_FAKE_FXA_AUTH and settings.DEBUG are both True, we serve a fake
# authentication page, bypassing FxA. To disable this behavior, set
# USE_FAKE_FXA = False in your local settings.
USE_FAKE_FXA_AUTH = True
# CSP report endpoint which returns a 204 from addons-nginx in local dev.
CSP_REPORT_URI = '/csp-report'
RESTRICTED_DOWNLOAD_CSP['REPORT_URI'] = CSP_REPORT_URI
# Set CSP like we do for dev/stage/prod, but also allow GA over http + www subdomain
# for local development.
HTTP_GA_SRC = 'http://www.google-analytics.com'
CSP_CONNECT_SRC += (SITE_URL,)
CSP_FONT_SRC += (STATIC_URL,)
CSP_IMG_SRC += (MEDIA_URL, STATIC_URL, HTTP_GA_SRC)
CSP_SCRIPT_SRC += (STATIC_URL, HTTP_GA_SRC)
CSP_STYLE_SRC += (STATIC_URL,)
# Auth token required to authorize inbound email.
INBOUND_EMAIL_SECRET_KEY = 'totally-unsecure-secret-string'
# Validation key we need to send in POST response.
INBOUND_EMAIL_VALIDATION_KEY = 'totally-unsecure-validation-string'
# Sectools
CUSTOMS_API_URL = 'http://customs:10101/'
CUSTOMS_API_KEY = 'customssecret'
REMOTE_SETTINGS_IS_TEST_SERVER = True
# If you have settings you want to overload, put them in a local_settings.py.
try:
from local_settings import * # noqa
2019-03-04 18:01:00 +03:00
except ImportError:
import warnings
import traceback
warnings.warn(
'Could not import local_settings module. {}'.format(traceback.format_exc())
)
SITEMAP_DEBUG_AVAILABLE = True