PageRenderTime 44ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/cms/envs/aws.py

https://gitlab.com/unofficial-mirrors/edx-platform
Python | 537 lines | 510 code | 9 blank | 18 comment | 2 complexity | 0114fb68098f200c6d0fabdea02979c9 MD5 | raw file
  1. """
  2. This is the default template for our main set of AWS servers.
  3. """
  4. # We intentionally define lots of variables that aren't used, and
  5. # want to import all variables from base settings files
  6. # pylint: disable=wildcard-import, unused-wildcard-import
  7. # Pylint gets confused by path.py instances, which report themselves as class
  8. # objects. As a result, pylint applies the wrong regex in validating names,
  9. # and throws spurious errors. Therefore, we disable invalid-name checking.
  10. # pylint: disable=invalid-name
  11. import json
  12. from .common import *
  13. from openedx.core.lib.derived import derive_settings
  14. from openedx.core.lib.logsettings import get_logger_config
  15. import os
  16. from path import Path as path
  17. from xmodule.modulestore.modulestore_settings import convert_module_store_setting_if_needed
  18. # SERVICE_VARIANT specifies name of the variant used, which decides what JSON
  19. # configuration files are read during startup.
  20. SERVICE_VARIANT = os.environ.get('SERVICE_VARIANT', None)
  21. # CONFIG_ROOT specifies the directory where the JSON configuration
  22. # files are expected to be found. If not specified, use the project
  23. # directory.
  24. CONFIG_ROOT = path(os.environ.get('CONFIG_ROOT', ENV_ROOT))
  25. # CONFIG_PREFIX specifies the prefix of the JSON configuration files,
  26. # based on the service variant. If no variant is use, don't use a
  27. # prefix.
  28. CONFIG_PREFIX = SERVICE_VARIANT + "." if SERVICE_VARIANT else ""
  29. ############### ALWAYS THE SAME ################################
  30. DEBUG = False
  31. EMAIL_BACKEND = 'django_ses.SESBackend'
  32. SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
  33. # IMPORTANT: With this enabled, the server must always be behind a proxy that
  34. # strips the header HTTP_X_FORWARDED_PROTO from client requests. Otherwise,
  35. # a user can fool our server into thinking it was an https connection.
  36. # See
  37. # https://docs.djangoproject.com/en/dev/ref/settings/#secure-proxy-ssl-header
  38. # for other warnings.
  39. SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
  40. ###################################### CELERY ################################
  41. # Don't use a connection pool, since connections are dropped by ELB.
  42. BROKER_POOL_LIMIT = 0
  43. BROKER_CONNECTION_TIMEOUT = 1
  44. # For the Result Store, use the django cache named 'celery'
  45. CELERY_RESULT_BACKEND = 'djcelery.backends.cache:CacheBackend'
  46. # When the broker is behind an ELB, use a heartbeat to refresh the
  47. # connection and to detect if it has been dropped.
  48. BROKER_HEARTBEAT = 60.0
  49. BROKER_HEARTBEAT_CHECKRATE = 2
  50. # Each worker should only fetch one message at a time
  51. CELERYD_PREFETCH_MULTIPLIER = 1
  52. # Rename the exchange and queues for each variant
  53. QUEUE_VARIANT = CONFIG_PREFIX.lower()
  54. CELERY_DEFAULT_EXCHANGE = 'edx.{0}core'.format(QUEUE_VARIANT)
  55. HIGH_PRIORITY_QUEUE = 'edx.{0}core.high'.format(QUEUE_VARIANT)
  56. DEFAULT_PRIORITY_QUEUE = 'edx.{0}core.default'.format(QUEUE_VARIANT)
  57. LOW_PRIORITY_QUEUE = 'edx.{0}core.low'.format(QUEUE_VARIANT)
  58. CELERY_DEFAULT_QUEUE = DEFAULT_PRIORITY_QUEUE
  59. CELERY_DEFAULT_ROUTING_KEY = DEFAULT_PRIORITY_QUEUE
  60. CELERY_QUEUES = {
  61. HIGH_PRIORITY_QUEUE: {},
  62. LOW_PRIORITY_QUEUE: {},
  63. DEFAULT_PRIORITY_QUEUE: {}
  64. }
  65. CELERY_ROUTES = "{}celery.Router".format(QUEUE_VARIANT)
  66. ############# NON-SECURE ENV CONFIG ##############################
  67. # Things like server locations, ports, etc.
  68. with open(CONFIG_ROOT / CONFIG_PREFIX + "env.json") as env_file:
  69. ENV_TOKENS = json.load(env_file)
  70. # STATIC_URL_BASE specifies the base url to use for static files
  71. STATIC_URL_BASE = ENV_TOKENS.get('STATIC_URL_BASE', None)
  72. if STATIC_URL_BASE:
  73. # collectstatic will fail if STATIC_URL is a unicode string
  74. STATIC_URL = STATIC_URL_BASE.encode('ascii')
  75. if not STATIC_URL.endswith("/"):
  76. STATIC_URL += "/"
  77. STATIC_URL += EDX_PLATFORM_REVISION + "/"
  78. # DEFAULT_COURSE_ABOUT_IMAGE_URL specifies the default image to show for courses that don't provide one
  79. DEFAULT_COURSE_ABOUT_IMAGE_URL = ENV_TOKENS.get('DEFAULT_COURSE_ABOUT_IMAGE_URL', DEFAULT_COURSE_ABOUT_IMAGE_URL)
  80. # MEDIA_ROOT specifies the directory where user-uploaded files are stored.
  81. MEDIA_ROOT = ENV_TOKENS.get('MEDIA_ROOT', MEDIA_ROOT)
  82. MEDIA_URL = ENV_TOKENS.get('MEDIA_URL', MEDIA_URL)
  83. # GITHUB_REPO_ROOT is the base directory
  84. # for course data
  85. GITHUB_REPO_ROOT = ENV_TOKENS.get('GITHUB_REPO_ROOT', GITHUB_REPO_ROOT)
  86. # STATIC_ROOT specifies the directory where static files are
  87. # collected
  88. STATIC_ROOT_BASE = ENV_TOKENS.get('STATIC_ROOT_BASE', None)
  89. if STATIC_ROOT_BASE:
  90. STATIC_ROOT = path(STATIC_ROOT_BASE) / EDX_PLATFORM_REVISION
  91. WEBPACK_LOADER['DEFAULT']['STATS_FILE'] = STATIC_ROOT / "webpack-stats.json"
  92. EMAIL_BACKEND = ENV_TOKENS.get('EMAIL_BACKEND', EMAIL_BACKEND)
  93. EMAIL_FILE_PATH = ENV_TOKENS.get('EMAIL_FILE_PATH', None)
  94. EMAIL_HOST = ENV_TOKENS.get('EMAIL_HOST', EMAIL_HOST)
  95. EMAIL_PORT = ENV_TOKENS.get('EMAIL_PORT', EMAIL_PORT)
  96. EMAIL_USE_TLS = ENV_TOKENS.get('EMAIL_USE_TLS', EMAIL_USE_TLS)
  97. LMS_BASE = ENV_TOKENS.get('LMS_BASE')
  98. LMS_ROOT_URL = ENV_TOKENS.get('LMS_ROOT_URL')
  99. # Note that FEATURES['PREVIEW_LMS_BASE'] gets read in from the environment file.
  100. SITE_NAME = ENV_TOKENS['SITE_NAME']
  101. ALLOWED_HOSTS = [
  102. # TODO: bbeggs remove this before prod, temp fix to get load testing running
  103. "*",
  104. ENV_TOKENS.get('CMS_BASE')
  105. ]
  106. LOG_DIR = ENV_TOKENS['LOG_DIR']
  107. CACHES = ENV_TOKENS['CACHES']
  108. # Cache used for location mapping -- called many times with the same key/value
  109. # in a given request.
  110. if 'loc_cache' not in CACHES:
  111. CACHES['loc_cache'] = {
  112. 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
  113. 'LOCATION': 'edx_location_mem_cache',
  114. }
  115. SESSION_COOKIE_DOMAIN = ENV_TOKENS.get('SESSION_COOKIE_DOMAIN')
  116. SESSION_COOKIE_HTTPONLY = ENV_TOKENS.get('SESSION_COOKIE_HTTPONLY', True)
  117. SESSION_ENGINE = ENV_TOKENS.get('SESSION_ENGINE', SESSION_ENGINE)
  118. SESSION_COOKIE_SECURE = ENV_TOKENS.get('SESSION_COOKIE_SECURE', SESSION_COOKIE_SECURE)
  119. SESSION_SAVE_EVERY_REQUEST = ENV_TOKENS.get('SESSION_SAVE_EVERY_REQUEST', SESSION_SAVE_EVERY_REQUEST)
  120. # social sharing settings
  121. SOCIAL_SHARING_SETTINGS = ENV_TOKENS.get('SOCIAL_SHARING_SETTINGS', SOCIAL_SHARING_SETTINGS)
  122. REGISTRATION_EMAIL_PATTERNS_ALLOWED = ENV_TOKENS.get('REGISTRATION_EMAIL_PATTERNS_ALLOWED')
  123. # allow for environments to specify what cookie name our login subsystem should use
  124. # this is to fix a bug regarding simultaneous logins between edx.org and edge.edx.org which can
  125. # happen with some browsers (e.g. Firefox)
  126. if ENV_TOKENS.get('SESSION_COOKIE_NAME', None):
  127. # NOTE, there's a bug in Django (http://bugs.python.org/issue18012) which necessitates this being a str()
  128. SESSION_COOKIE_NAME = str(ENV_TOKENS.get('SESSION_COOKIE_NAME'))
  129. # Set the names of cookies shared with the marketing site
  130. # These have the same cookie domain as the session, which in production
  131. # usually includes subdomains.
  132. EDXMKTG_LOGGED_IN_COOKIE_NAME = ENV_TOKENS.get('EDXMKTG_LOGGED_IN_COOKIE_NAME', EDXMKTG_LOGGED_IN_COOKIE_NAME)
  133. EDXMKTG_USER_INFO_COOKIE_NAME = ENV_TOKENS.get('EDXMKTG_USER_INFO_COOKIE_NAME', EDXMKTG_USER_INFO_COOKIE_NAME)
  134. # Determines whether the CSRF token can be transported on
  135. # unencrypted channels. It is set to False here for backward compatibility,
  136. # but it is highly recommended that this is True for environments accessed
  137. # by end users.
  138. CSRF_COOKIE_SECURE = ENV_TOKENS.get('CSRF_COOKIE_SECURE', False)
  139. #Email overrides
  140. DEFAULT_FROM_EMAIL = ENV_TOKENS.get('DEFAULT_FROM_EMAIL', DEFAULT_FROM_EMAIL)
  141. DEFAULT_FEEDBACK_EMAIL = ENV_TOKENS.get('DEFAULT_FEEDBACK_EMAIL', DEFAULT_FEEDBACK_EMAIL)
  142. ADMINS = ENV_TOKENS.get('ADMINS', ADMINS)
  143. SERVER_EMAIL = ENV_TOKENS.get('SERVER_EMAIL', SERVER_EMAIL)
  144. MKTG_URLS = ENV_TOKENS.get('MKTG_URLS', MKTG_URLS)
  145. TECH_SUPPORT_EMAIL = ENV_TOKENS.get('TECH_SUPPORT_EMAIL', TECH_SUPPORT_EMAIL)
  146. for name, value in ENV_TOKENS.get("CODE_JAIL", {}).items():
  147. oldvalue = CODE_JAIL.get(name)
  148. if isinstance(oldvalue, dict):
  149. for subname, subvalue in value.items():
  150. oldvalue[subname] = subvalue
  151. else:
  152. CODE_JAIL[name] = value
  153. COURSES_WITH_UNSAFE_CODE = ENV_TOKENS.get("COURSES_WITH_UNSAFE_CODE", [])
  154. ASSET_IGNORE_REGEX = ENV_TOKENS.get('ASSET_IGNORE_REGEX', ASSET_IGNORE_REGEX)
  155. COMPREHENSIVE_THEME_DIRS = ENV_TOKENS.get('COMPREHENSIVE_THEME_DIRS', COMPREHENSIVE_THEME_DIRS) or []
  156. # COMPREHENSIVE_THEME_LOCALE_PATHS contain the paths to themes locale directories e.g.
  157. # "COMPREHENSIVE_THEME_LOCALE_PATHS" : [
  158. # "/edx/src/edx-themes/conf/locale"
  159. # ],
  160. COMPREHENSIVE_THEME_LOCALE_PATHS = ENV_TOKENS.get('COMPREHENSIVE_THEME_LOCALE_PATHS', [])
  161. DEFAULT_SITE_THEME = ENV_TOKENS.get('DEFAULT_SITE_THEME', DEFAULT_SITE_THEME)
  162. ENABLE_COMPREHENSIVE_THEMING = ENV_TOKENS.get('ENABLE_COMPREHENSIVE_THEMING', ENABLE_COMPREHENSIVE_THEMING)
  163. #Timezone overrides
  164. TIME_ZONE = ENV_TOKENS.get('TIME_ZONE', TIME_ZONE)
  165. # Push to LMS overrides
  166. GIT_REPO_EXPORT_DIR = ENV_TOKENS.get('GIT_REPO_EXPORT_DIR', '/edx/var/edxapp/export_course_repos')
  167. # Translation overrides
  168. LANGUAGES = ENV_TOKENS.get('LANGUAGES', LANGUAGES)
  169. LANGUAGE_CODE = ENV_TOKENS.get('LANGUAGE_CODE', LANGUAGE_CODE)
  170. LANGUAGE_COOKIE = ENV_TOKENS.get('LANGUAGE_COOKIE', LANGUAGE_COOKIE)
  171. USE_I18N = ENV_TOKENS.get('USE_I18N', USE_I18N)
  172. ENV_FEATURES = ENV_TOKENS.get('FEATURES', {})
  173. for feature, value in ENV_FEATURES.items():
  174. FEATURES[feature] = value
  175. # Additional installed apps
  176. for app in ENV_TOKENS.get('ADDL_INSTALLED_APPS', []):
  177. INSTALLED_APPS.append(app)
  178. WIKI_ENABLED = ENV_TOKENS.get('WIKI_ENABLED', WIKI_ENABLED)
  179. LOGGING = get_logger_config(LOG_DIR,
  180. logging_env=ENV_TOKENS['LOGGING_ENV'],
  181. debug=False,
  182. service_variant=SERVICE_VARIANT)
  183. #theming start:
  184. PLATFORM_NAME = ENV_TOKENS.get('PLATFORM_NAME', PLATFORM_NAME)
  185. PLATFORM_DESCRIPTION = ENV_TOKENS.get('PLATFORM_DESCRIPTION', PLATFORM_DESCRIPTION)
  186. STUDIO_NAME = ENV_TOKENS.get('STUDIO_NAME', STUDIO_NAME)
  187. STUDIO_SHORT_NAME = ENV_TOKENS.get('STUDIO_SHORT_NAME', STUDIO_SHORT_NAME)
  188. # Event Tracking
  189. if "TRACKING_IGNORE_URL_PATTERNS" in ENV_TOKENS:
  190. TRACKING_IGNORE_URL_PATTERNS = ENV_TOKENS.get("TRACKING_IGNORE_URL_PATTERNS")
  191. # Django CAS external authentication settings
  192. CAS_EXTRA_LOGIN_PARAMS = ENV_TOKENS.get("CAS_EXTRA_LOGIN_PARAMS", None)
  193. if FEATURES.get('AUTH_USE_CAS'):
  194. CAS_SERVER_URL = ENV_TOKENS.get("CAS_SERVER_URL", None)
  195. AUTHENTICATION_BACKENDS = [
  196. 'django.contrib.auth.backends.ModelBackend',
  197. 'django_cas.backends.CASBackend',
  198. ]
  199. INSTALLED_APPS.append('django_cas')
  200. MIDDLEWARE_CLASSES.append('django_cas.middleware.CASMiddleware')
  201. CAS_ATTRIBUTE_CALLBACK = ENV_TOKENS.get('CAS_ATTRIBUTE_CALLBACK', None)
  202. if CAS_ATTRIBUTE_CALLBACK:
  203. import importlib
  204. CAS_USER_DETAILS_RESOLVER = getattr(
  205. importlib.import_module(CAS_ATTRIBUTE_CALLBACK['module']),
  206. CAS_ATTRIBUTE_CALLBACK['function']
  207. )
  208. # Specific setting for the File Upload Service to store media in a bucket.
  209. FILE_UPLOAD_STORAGE_BUCKET_NAME = ENV_TOKENS.get('FILE_UPLOAD_STORAGE_BUCKET_NAME', FILE_UPLOAD_STORAGE_BUCKET_NAME)
  210. FILE_UPLOAD_STORAGE_PREFIX = ENV_TOKENS.get('FILE_UPLOAD_STORAGE_PREFIX', FILE_UPLOAD_STORAGE_PREFIX)
  211. ################ SECURE AUTH ITEMS ###############################
  212. # Secret things: passwords, access keys, etc.
  213. with open(CONFIG_ROOT / CONFIG_PREFIX + "auth.json") as auth_file:
  214. AUTH_TOKENS = json.load(auth_file)
  215. ############### XBlock filesystem field config ##########
  216. if 'DJFS' in AUTH_TOKENS and AUTH_TOKENS['DJFS'] is not None:
  217. DJFS = AUTH_TOKENS['DJFS']
  218. if 'url_root' in DJFS:
  219. DJFS['url_root'] = DJFS['url_root'].format(platform_revision=EDX_PLATFORM_REVISION)
  220. EMAIL_HOST_USER = AUTH_TOKENS.get('EMAIL_HOST_USER', EMAIL_HOST_USER)
  221. EMAIL_HOST_PASSWORD = AUTH_TOKENS.get('EMAIL_HOST_PASSWORD', EMAIL_HOST_PASSWORD)
  222. AWS_SES_REGION_NAME = ENV_TOKENS.get('AWS_SES_REGION_NAME', 'us-east-1')
  223. AWS_SES_REGION_ENDPOINT = ENV_TOKENS.get('AWS_SES_REGION_ENDPOINT', 'email.us-east-1.amazonaws.com')
  224. # Note that this is the Studio key for Segment. There is a separate key for the LMS.
  225. CMS_SEGMENT_KEY = AUTH_TOKENS.get('SEGMENT_KEY')
  226. SECRET_KEY = AUTH_TOKENS['SECRET_KEY']
  227. AWS_ACCESS_KEY_ID = AUTH_TOKENS["AWS_ACCESS_KEY_ID"]
  228. if AWS_ACCESS_KEY_ID == "":
  229. AWS_ACCESS_KEY_ID = None
  230. AWS_SECRET_ACCESS_KEY = AUTH_TOKENS["AWS_SECRET_ACCESS_KEY"]
  231. if AWS_SECRET_ACCESS_KEY == "":
  232. AWS_SECRET_ACCESS_KEY = None
  233. AWS_STORAGE_BUCKET_NAME = AUTH_TOKENS.get('AWS_STORAGE_BUCKET_NAME', 'edxuploads')
  234. # Disabling querystring auth instructs Boto to exclude the querystring parameters (e.g. signature, access key) it
  235. # normally appends to every returned URL.
  236. AWS_QUERYSTRING_AUTH = AUTH_TOKENS.get('AWS_QUERYSTRING_AUTH', True)
  237. AWS_DEFAULT_ACL = 'private'
  238. AWS_BUCKET_ACL = AWS_DEFAULT_ACL
  239. AWS_QUERYSTRING_EXPIRE = 7 * 24 * 60 * 60 # 7 days
  240. AWS_S3_CUSTOM_DOMAIN = AUTH_TOKENS.get('AWS_S3_CUSTOM_DOMAIN', 'edxuploads.s3.amazonaws.com')
  241. if AUTH_TOKENS.get('DEFAULT_FILE_STORAGE'):
  242. DEFAULT_FILE_STORAGE = AUTH_TOKENS.get('DEFAULT_FILE_STORAGE')
  243. elif AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY:
  244. DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
  245. else:
  246. DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
  247. COURSE_IMPORT_EXPORT_BUCKET = ENV_TOKENS.get('COURSE_IMPORT_EXPORT_BUCKET', '')
  248. if COURSE_IMPORT_EXPORT_BUCKET:
  249. COURSE_IMPORT_EXPORT_STORAGE = 'contentstore.storage.ImportExportS3Storage'
  250. else:
  251. COURSE_IMPORT_EXPORT_STORAGE = DEFAULT_FILE_STORAGE
  252. USER_TASKS_ARTIFACT_STORAGE = COURSE_IMPORT_EXPORT_STORAGE
  253. DATABASES = AUTH_TOKENS['DATABASES']
  254. # The normal database user does not have enough permissions to run migrations.
  255. # Migrations are run with separate credentials, given as DB_MIGRATION_*
  256. # environment variables
  257. for name, database in DATABASES.items():
  258. if name != 'read_replica':
  259. database.update({
  260. 'ENGINE': os.environ.get('DB_MIGRATION_ENGINE', database['ENGINE']),
  261. 'USER': os.environ.get('DB_MIGRATION_USER', database['USER']),
  262. 'PASSWORD': os.environ.get('DB_MIGRATION_PASS', database['PASSWORD']),
  263. 'NAME': os.environ.get('DB_MIGRATION_NAME', database['NAME']),
  264. 'HOST': os.environ.get('DB_MIGRATION_HOST', database['HOST']),
  265. 'PORT': os.environ.get('DB_MIGRATION_PORT', database['PORT']),
  266. })
  267. MODULESTORE = convert_module_store_setting_if_needed(AUTH_TOKENS.get('MODULESTORE', MODULESTORE))
  268. MODULESTORE_FIELD_OVERRIDE_PROVIDERS = ENV_TOKENS.get(
  269. 'MODULESTORE_FIELD_OVERRIDE_PROVIDERS',
  270. MODULESTORE_FIELD_OVERRIDE_PROVIDERS
  271. )
  272. XBLOCK_FIELD_DATA_WRAPPERS = ENV_TOKENS.get(
  273. 'XBLOCK_FIELD_DATA_WRAPPERS',
  274. XBLOCK_FIELD_DATA_WRAPPERS
  275. )
  276. CONTENTSTORE = AUTH_TOKENS['CONTENTSTORE']
  277. DOC_STORE_CONFIG = AUTH_TOKENS['DOC_STORE_CONFIG']
  278. # Datadog for events!
  279. DATADOG = AUTH_TOKENS.get("DATADOG", {})
  280. DATADOG.update(ENV_TOKENS.get("DATADOG", {}))
  281. # TODO: deprecated (compatibility with previous settings)
  282. if 'DATADOG_API' in AUTH_TOKENS:
  283. DATADOG['api_key'] = AUTH_TOKENS['DATADOG_API']
  284. # Celery Broker
  285. CELERY_ALWAYS_EAGER = ENV_TOKENS.get("CELERY_ALWAYS_EAGER", False)
  286. CELERY_BROKER_TRANSPORT = ENV_TOKENS.get("CELERY_BROKER_TRANSPORT", "")
  287. CELERY_BROKER_HOSTNAME = ENV_TOKENS.get("CELERY_BROKER_HOSTNAME", "")
  288. CELERY_BROKER_VHOST = ENV_TOKENS.get("CELERY_BROKER_VHOST", "")
  289. CELERY_BROKER_USER = AUTH_TOKENS.get("CELERY_BROKER_USER", "")
  290. CELERY_BROKER_PASSWORD = AUTH_TOKENS.get("CELERY_BROKER_PASSWORD", "")
  291. BROKER_URL = "{0}://{1}:{2}@{3}/{4}".format(CELERY_BROKER_TRANSPORT,
  292. CELERY_BROKER_USER,
  293. CELERY_BROKER_PASSWORD,
  294. CELERY_BROKER_HOSTNAME,
  295. CELERY_BROKER_VHOST)
  296. BROKER_USE_SSL = ENV_TOKENS.get('CELERY_BROKER_USE_SSL', False)
  297. # Message expiry time in seconds
  298. CELERY_EVENT_QUEUE_TTL = ENV_TOKENS.get('CELERY_EVENT_QUEUE_TTL', None)
  299. # Allow CELERY_QUEUES to be overwritten by ENV_TOKENS,
  300. ENV_CELERY_QUEUES = ENV_TOKENS.get('CELERY_QUEUES', None)
  301. if ENV_CELERY_QUEUES:
  302. CELERY_QUEUES = {queue: {} for queue in ENV_CELERY_QUEUES}
  303. # Then add alternate environment queues
  304. ALTERNATE_QUEUE_ENVS = ENV_TOKENS.get('ALTERNATE_WORKER_QUEUES', '').split()
  305. ALTERNATE_QUEUES = [
  306. DEFAULT_PRIORITY_QUEUE.replace(QUEUE_VARIANT, alternate + '.')
  307. for alternate in ALTERNATE_QUEUE_ENVS
  308. ]
  309. CELERY_QUEUES.update(
  310. {
  311. alternate: {}
  312. for alternate in ALTERNATE_QUEUES
  313. if alternate not in CELERY_QUEUES.keys()
  314. }
  315. )
  316. # Queue to use for updating grades due to grading policy change
  317. POLICY_CHANGE_GRADES_ROUTING_KEY = ENV_TOKENS.get('POLICY_CHANGE_GRADES_ROUTING_KEY', LOW_PRIORITY_QUEUE)
  318. # Event tracking
  319. TRACKING_BACKENDS.update(AUTH_TOKENS.get("TRACKING_BACKENDS", {}))
  320. EVENT_TRACKING_BACKENDS['tracking_logs']['OPTIONS']['backends'].update(AUTH_TOKENS.get("EVENT_TRACKING_BACKENDS", {}))
  321. EVENT_TRACKING_BACKENDS['segmentio']['OPTIONS']['processors'][0]['OPTIONS']['whitelist'].extend(
  322. AUTH_TOKENS.get("EVENT_TRACKING_SEGMENTIO_EMIT_WHITELIST", []))
  323. VIRTUAL_UNIVERSITIES = ENV_TOKENS.get('VIRTUAL_UNIVERSITIES', [])
  324. ##### ACCOUNT LOCKOUT DEFAULT PARAMETERS #####
  325. MAX_FAILED_LOGIN_ATTEMPTS_ALLOWED = ENV_TOKENS.get("MAX_FAILED_LOGIN_ATTEMPTS_ALLOWED", 5)
  326. MAX_FAILED_LOGIN_ATTEMPTS_LOCKOUT_PERIOD_SECS = ENV_TOKENS.get("MAX_FAILED_LOGIN_ATTEMPTS_LOCKOUT_PERIOD_SECS", 15 * 60)
  327. #### PASSWORD POLICY SETTINGS #####
  328. PASSWORD_MIN_LENGTH = ENV_TOKENS.get("PASSWORD_MIN_LENGTH")
  329. PASSWORD_MAX_LENGTH = ENV_TOKENS.get("PASSWORD_MAX_LENGTH")
  330. PASSWORD_COMPLEXITY = ENV_TOKENS.get("PASSWORD_COMPLEXITY", {})
  331. PASSWORD_DICTIONARY_EDIT_DISTANCE_THRESHOLD = ENV_TOKENS.get("PASSWORD_DICTIONARY_EDIT_DISTANCE_THRESHOLD")
  332. PASSWORD_DICTIONARY = ENV_TOKENS.get("PASSWORD_DICTIONARY", [])
  333. ### INACTIVITY SETTINGS ####
  334. SESSION_INACTIVITY_TIMEOUT_IN_SECONDS = AUTH_TOKENS.get("SESSION_INACTIVITY_TIMEOUT_IN_SECONDS")
  335. ##### X-Frame-Options response header settings #####
  336. X_FRAME_OPTIONS = ENV_TOKENS.get('X_FRAME_OPTIONS', X_FRAME_OPTIONS)
  337. ##### ADVANCED_SECURITY_CONFIG #####
  338. ADVANCED_SECURITY_CONFIG = ENV_TOKENS.get('ADVANCED_SECURITY_CONFIG', {})
  339. ################ ADVANCED COMPONENT/PROBLEM TYPES ###############
  340. ADVANCED_PROBLEM_TYPES = ENV_TOKENS.get('ADVANCED_PROBLEM_TYPES', ADVANCED_PROBLEM_TYPES)
  341. ################ VIDEO UPLOAD PIPELINE ###############
  342. VIDEO_UPLOAD_PIPELINE = ENV_TOKENS.get('VIDEO_UPLOAD_PIPELINE', VIDEO_UPLOAD_PIPELINE)
  343. ################ VIDEO IMAGE STORAGE ###############
  344. VIDEO_IMAGE_SETTINGS = ENV_TOKENS.get('VIDEO_IMAGE_SETTINGS', VIDEO_IMAGE_SETTINGS)
  345. ################ VIDEO TRANSCRIPTS STORAGE ###############
  346. VIDEO_TRANSCRIPTS_SETTINGS = ENV_TOKENS.get('VIDEO_TRANSCRIPTS_SETTINGS', VIDEO_TRANSCRIPTS_SETTINGS)
  347. ################ PUSH NOTIFICATIONS ###############
  348. PARSE_KEYS = AUTH_TOKENS.get("PARSE_KEYS", {})
  349. # Video Caching. Pairing country codes with CDN URLs.
  350. # Example: {'CN': 'http://api.xuetangx.com/edx/video?s3_url='}
  351. VIDEO_CDN_URL = ENV_TOKENS.get('VIDEO_CDN_URL', {})
  352. if FEATURES['ENABLE_COURSEWARE_INDEX'] or FEATURES['ENABLE_LIBRARY_INDEX']:
  353. # Use ElasticSearch for the search engine
  354. SEARCH_ENGINE = "search.elastic.ElasticSearchEngine"
  355. ELASTIC_SEARCH_CONFIG = ENV_TOKENS.get('ELASTIC_SEARCH_CONFIG', [{}])
  356. XBLOCK_SETTINGS = ENV_TOKENS.get('XBLOCK_SETTINGS', {})
  357. XBLOCK_SETTINGS.setdefault("VideoDescriptor", {})["licensing_enabled"] = FEATURES.get("LICENSING", False)
  358. XBLOCK_SETTINGS.setdefault("VideoModule", {})['YOUTUBE_API_KEY'] = AUTH_TOKENS.get('YOUTUBE_API_KEY', YOUTUBE_API_KEY)
  359. ################# PROCTORING CONFIGURATION ##################
  360. PROCTORING_BACKEND_PROVIDER = AUTH_TOKENS.get("PROCTORING_BACKEND_PROVIDER", PROCTORING_BACKEND_PROVIDER)
  361. PROCTORING_SETTINGS = ENV_TOKENS.get("PROCTORING_SETTINGS", PROCTORING_SETTINGS)
  362. ################# MICROSITE ####################
  363. # microsite specific configurations.
  364. MICROSITE_CONFIGURATION = ENV_TOKENS.get('MICROSITE_CONFIGURATION', {})
  365. MICROSITE_ROOT_DIR = path(ENV_TOKENS.get('MICROSITE_ROOT_DIR', ''))
  366. # this setting specify which backend to be used when pulling microsite specific configuration
  367. MICROSITE_BACKEND = ENV_TOKENS.get("MICROSITE_BACKEND", MICROSITE_BACKEND)
  368. # this setting specify which backend to be used when loading microsite specific templates
  369. MICROSITE_TEMPLATE_BACKEND = ENV_TOKENS.get("MICROSITE_TEMPLATE_BACKEND", MICROSITE_TEMPLATE_BACKEND)
  370. # TTL for microsite database template cache
  371. MICROSITE_DATABASE_TEMPLATE_CACHE_TTL = ENV_TOKENS.get(
  372. "MICROSITE_DATABASE_TEMPLATE_CACHE_TTL", MICROSITE_DATABASE_TEMPLATE_CACHE_TTL
  373. )
  374. ############################ OAUTH2 Provider ###################################
  375. # OpenID Connect issuer ID. Normally the URL of the authentication endpoint.
  376. OAUTH_OIDC_ISSUER = ENV_TOKENS['OAUTH_OIDC_ISSUER']
  377. #### JWT configuration ####
  378. JWT_AUTH.update(ENV_TOKENS.get('JWT_AUTH', {}))
  379. ######################## CUSTOM COURSES for EDX CONNECTOR ######################
  380. if FEATURES.get('CUSTOM_COURSES_EDX'):
  381. INSTALLED_APPS.append('openedx.core.djangoapps.ccxcon.apps.CCXConnectorConfig')
  382. # Partner support link for CMS footer
  383. PARTNER_SUPPORT_EMAIL = ENV_TOKENS.get('PARTNER_SUPPORT_EMAIL', PARTNER_SUPPORT_EMAIL)
  384. # Affiliate cookie tracking
  385. AFFILIATE_COOKIE_NAME = ENV_TOKENS.get('AFFILIATE_COOKIE_NAME', AFFILIATE_COOKIE_NAME)
  386. ############## Settings for Studio Context Sensitive Help ##############
  387. HELP_TOKENS_BOOKS = ENV_TOKENS.get('HELP_TOKENS_BOOKS', HELP_TOKENS_BOOKS)
  388. ############## Settings for CourseGraph ############################
  389. COURSEGRAPH_JOB_QUEUE = ENV_TOKENS.get('COURSEGRAPH_JOB_QUEUE', LOW_PRIORITY_QUEUE)
  390. ########################## Parental controls config #######################
  391. # The age at which a learner no longer requires parental consent, or None
  392. # if parental consent is never required.
  393. PARENTAL_CONSENT_AGE_LIMIT = ENV_TOKENS.get(
  394. 'PARENTAL_CONSENT_AGE_LIMIT',
  395. PARENTAL_CONSENT_AGE_LIMIT
  396. )
  397. ########################## Extra middleware classes #######################
  398. # Allow extra middleware classes to be added to the app through configuration.
  399. MIDDLEWARE_CLASSES.extend(ENV_TOKENS.get('EXTRA_MIDDLEWARE_CLASSES', []))
  400. ########################## Derive Any Derived Settings #######################
  401. derive_settings(__name__)