Skip to content

Commit 1593923

Browse files
kdmccormickfeanil
andauthored
refactor: Clean up lms/envs/production.py cruft (#36115)
This is a pure refactoring of lms/envs/production.py, removing several redundant statements that have accrued over the years as the platform moved from python-only, to python+json, to python+json+yaml, to today's python+yaml setup. Notes on some of the more involved refactorings: * AWS Locals Load block is handled by the YAML loading at the very top, we don't need to re-load it since there were no changes to those settings between the YAML loading at the top and this section. * MKTG_URL_OVERRIDES, we drop doing any overrides and remove it from the merge list beacuse the default value in lms/envs/common.py is empty. So the update is a no-op and is the same as just loading this data directly from the YAML config. * CODE_JAIL block, we've been overriding the entire dict if it is in your YAML config, so then going through and updating the individual values is not necessary. * SSL_AUTH_EMAIL_DOMAIN and SSL_AUTH_DN_FORMAT_STRING are not used anywhere in the openedx org, looks like they were used by the old `dashboard` djangoapp and can probably be deleted but might be used by plugins so not removing for now to keep the change backward compatible. * DEFAULT_FILE_STORAGE, previously two of the braches were no-ops so we only keep the one branch we need for when we want to update DEFAULT_FILE_STORAGE automatically if AWS keys are set. Somewhat related to: openedx/openedx-proposals#587 Co-Authored-By: Feanil Patel <feanil@axim.org>
1 parent e930bc6 commit 1593923

File tree

2 files changed

+225
-678
lines changed

2 files changed

+225
-678
lines changed

lms/envs/common.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3392,9 +3392,35 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring
33923392
CSRF_COOKIE_SECURE = False
33933393
CSRF_TRUSTED_ORIGINS = []
33943394
CSRF_TRUSTED_ORIGINS_WITH_SCHEME = []
3395-
CROSS_DOMAIN_CSRF_COOKIE_DOMAIN = ''
3395+
3396+
# If setting a cross-domain cookie, it's really important to choose
3397+
# a name for the cookie that is DIFFERENT than the cookies used
3398+
# by each subdomain. For example, suppose the applications
3399+
# at these subdomains are configured to use the following cookie names:
3400+
#
3401+
# 1) foo.example.com --> "csrftoken"
3402+
# 2) baz.example.com --> "csrftoken"
3403+
# 3) bar.example.com --> "csrftoken"
3404+
#
3405+
# For the cross-domain version of the CSRF cookie, you need to choose
3406+
# a name DIFFERENT than "csrftoken"; otherwise, the new token configured
3407+
# for ".example.com" could conflict with the other cookies,
3408+
# non-deterministically causing 403 responses.
33963409
CROSS_DOMAIN_CSRF_COOKIE_NAME = ''
33973410

3411+
# When setting the domain for the "cross-domain" version of the CSRF
3412+
# cookie, you should choose something like: ".example.com"
3413+
# (note the leading dot), where both the referer and the host
3414+
# are subdomains of "example.com".
3415+
#
3416+
# Browser security rules require that
3417+
# the cookie domain matches the domain of the server; otherwise
3418+
# the cookie won't get set. And once the cookie gets set, the client
3419+
# needs to be on a domain that matches the cookie domain, otherwise
3420+
# the client won't be able to read the cookie.
3421+
CROSS_DOMAIN_CSRF_COOKIE_DOMAIN = ''
3422+
3423+
33983424
######################### Django Rest Framework ########################
33993425

34003426
REST_FRAMEWORK = {

0 commit comments

Comments
 (0)