Add missing CMS config (just in case)

I don't think this affects the CMS behaviour, but SESSION_COOKIE_DOMAIN
is used by the CMS, so rather be safe than sorry.
This commit is contained in:
Régis Behmo 2019-03-23 16:07:50 -07:00
parent 328cd2b1ac
commit a7ab1c5ace
5 changed files with 25 additions and 1 deletions

View File

@ -1,5 +1,9 @@
# Changelog
## Latest
- [Improvement] Support CMS login when the CMS is not a subdomain of the LMS
## 3.3.0 (2019-03-22)
- [Feature] Upgrade from Hawthorn to Ironwood

View File

@ -164,6 +164,9 @@ def load_defaults(config):
if k not in config:
config[k] = v
# Add extra configuration parameters that need to be computed separately
config["lms_cms_common_domain"] = utils.common_domain(config["LMS_HOST"], config["CMS_HOST"])
def ask(question, key, config):
default = env.render_str(config, config[key])
config[key] = click.prompt(

View File

@ -33,6 +33,7 @@
"EMAIL_PORT": {{ SMTP_PORT }},
"HTTPS": "{{ "on" if ACTIVATE_HTTPS else "off" }}",
"LANGUAGE_CODE": "{{ LANGUAGE_CODE }}",
"SESSION_COOKIE_DOMAIN": ".{{ lms_cms_common_domain }}",
"CACHES": {
"default": {
"KEY_PREFIX": "default",

View File

@ -44,7 +44,7 @@
{% endif %}
"LANGUAGE_CODE": "{{ LANGUAGE_CODE }}",
"LOGIN_REDIRECT_WHITELIST": ["{{ CMS_HOST }}", "studio.localhost"],
"SESSION_COOKIE_DOMAIN": ".{{ LMS_HOST }}",
"SESSION_COOKIE_DOMAIN": ".{{ lms_cms_common_domain }}",
"CACHES": {
"default": {
"KEY_PREFIX": "default",

View File

@ -21,6 +21,22 @@ def parse_yaml_value(v):
v = (v == "true")
return v
def common_domain(d1, d2):
"""
Return the common domain between two domain names.
Ex: "sub1.domain.com" and "sub2.domain.com" -> "domain.com"
"""
components1 = d1.split(".")[::-1]
components2 = d2.split(".")[::-1]
common = []
for c in range(0, min(len(components1), len(components2))):
if components1[c] == components2[c]:
common.append(components1[c])
else:
break
return ".".join(common[::-1])
def docker_run(*command):
return docker("run", "--rm", "-it", *command)