Skip to content

Commit

Permalink
fix: refactor MFE settings for Palm
Browse files Browse the repository at this point in the history
  • Loading branch information
lpm0073 committed Jan 3, 2024
1 parent d16ea93 commit 0923d14
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 109 deletions.
2 changes: 1 addition & 1 deletion tutork8s_deploy_tasks/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "17.0.0"
__version__ = "16.0.1"
126 changes: 72 additions & 54 deletions tutork8s_deploy_tasks/patches/openedx-cms-production-settings
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,89 @@
#
# copied from: https://github.com/overhangio/tutor-mfe/blob/master/tutormfe/patches/openedx-lms-production-settings
#------------------------------------------------------------------------------
{% if MFE_ACCOUNT_MFE_APP %}
ACCOUNT_MICROFRONTEND_URL = "https://{{ MFE_HOST }}/{{ MFE_ACCOUNT_MFE_APP["name"] }}"
{% endif %}
{% if MFE_GRADEBOOK_MFE_APP %}
WRITABLE_GRADEBOOK_URL = "https://{{ MFE_HOST }}/{{ MFE_GRADEBOOK_MFE_APP["name"] }}"
# Dynamic config API settings
# https://openedx.github.io/frontend-platform/module-Config.html
MFE_CONFIG = {
"BASE_URL": "{{ MFE_HOST }}",
"CSRF_TOKEN_API_PATH": "/csrf/api/v1/token",
"CREDENTIALS_BASE_URL": "",
"DISCOVERY_API_BASE_URL": "{% if DISCOVERY_HOST is defined %}{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ DISCOVERY_HOST }}{% endif %}",
"FAVICON_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/favicon.ico",
"INFO_EMAIL": "{{ CONTACT_EMAIL }}",
"LANGUAGE_PREFERENCE_COOKIE_NAME": "openedx-language-preference",
"LMS_BASE_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}",
"LOGIN_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/login",
"LOGO_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/theming/asset/images/logo.png",
"LOGO_WHITE_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/theming/asset/images/logo.png",
"LOGO_TRADEMARK_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/theming/asset/images/logo.png",
"LOGOUT_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/logout",
"MARKETING_SITE_BASE_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}",
"PASSWORD_RESET_SUPPORT_LINK": "mailto:{{ CONTACT_EMAIL }}",
"REFRESH_ACCESS_TOKEN_ENDPOINT": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/login_refresh",
"SITE_NAME": "{{ PLATFORM_NAME }}",
"STUDIO_BASE_URL": "{{ "https" if ENABLE_HTTPS else "http" }}://{{ CMS_HOST }}",
"USER_INFO_COOKIE_NAME": "user-info",
"ACCESS_TOKEN_COOKIE_NAME": "edx-jwt-cookie-header-payload",
}

# MFE-specific settings

{% if get_mfe("authn") %}
AUTHN_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/authn"
AUTHN_MICROFRONTEND_DOMAIN = "{{ MFE_HOST }}/authn"
MFE_CONFIG["DISABLE_ENTERPRISE_LOGIN"] = True
{% endif %}
{% if MFE_LEARNING_MFE_APP %}
LEARNING_MICROFRONTEND_URL = "https://{{ MFE_HOST }}/{{ MFE_LEARNING_MFE_APP["name"] }}"

{% if get_mfe("account") %}
ACCOUNT_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/account/"
MFE_CONFIG["ACCOUNT_SETTINGS_URL"] = ACCOUNT_MICROFRONTEND_URL
{% endif %}
{% if MFE_PROFILE_MFE_APP %}
PROFILE_MICROFRONTEND_URL = "https://{{ MFE_HOST }}/{{ MFE_PROFILE_MFE_APP["name"] }}/u/"

{% if get_mfe("course-authoring") %}
MFE_CONFIG["ENABLE_NEW_EDITOR_PAGES"] = True
MFE_CONFIG["ENABLE_PROGRESS_GRAPH_SETTINGS"] = True
{% endif %}
{% if MFE_DISCUSSIONS_MFE_APP %}
DISCUSSIONS_MICROFRONTEND_URL = "https://{{ MFE_HOST }}/{{ MFE_DISCUSSIONS_MFE_APP["name"] }}"

{% if get_mfe("discussions") %}
DISCUSSIONS_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/discussions"
MFE_CONFIG["DISCUSSIONS_MFE_BASE_URL"] = DISCUSSIONS_MICROFRONTEND_URL
DISCUSSIONS_MFE_FEEDBACK_URL = None
{% endif %}

{% if MFE_AUTHN_MFE_APP %}
AUTHN_MICROFRONTEND_URL = "https://{{ MFE_HOST }}/{{ MFE_AUTHN_MFE_APP["name"] }}"
AUTHN_MICROFRONTEND_DOMAIN = "{{ MFE_HOST }}/{{ MFE_AUTHN_MFE_APP["name"] }}"
{% if get_mfe("gradebook") %}
WRITABLE_GRADEBOOK_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/gradebook"
{% endif %}

{% if get_mfe("learner-dashboard") %}
LEARNER_HOME_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/learner-dashboard/"
{% endif %}

{% if get_mfe("learning") %}
LEARNING_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/learning"
MFE_CONFIG["LEARNING_BASE_URL"] = "{{ "https" if ENABLE_HTTPS else "http" }}://{{ MFE_HOST }}/learning"
{% endif %}

{% if get_mfe("ora-grading") %}
ORA_GRADING_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/ora-grading"
{% endif %}

{% if get_mfe("profile") %}
PROFILE_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/profile/u/"
MFE_CONFIG["ACCOUNT_PROFILE_URL"] = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/profile"
{% endif %}

{% if get_mfe("communications") %}
COMMUNICATIONS_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/communications"
MFE_CONFIG["SCHEDULE_EMAIL_SECTION"] = True
{% endif %}

LOGIN_REDIRECT_WHITELIST.append("{{ MFE_HOST }}")
CSRF_TRUSTED_ORIGINS.append("{{ MFE_HOST }}")
CORS_ORIGIN_WHITELIST.append("{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}")
CSRF_TRUSTED_ORIGINS.append("{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}")

# add missing CORS_ORIGIN_WHITELIST hosts
CORS_ORIGIN_WHITELIST.append("https://{{ LMS_HOST }}")
CORS_ORIGIN_WHITELIST.append("https://{{ CMS_HOST }}")
{% if MFE_HOST is defined %}
CORS_ORIGIN_WHITELIST.append("https://{{ MFE_HOST }}")
{% endif %}
{% if DISCOVERY_HOST is defined %}
CORS_ORIGIN_WHITELIST.append("https://{{ DISCOVERY_HOST }}")
{% endif %}
Expand All @@ -47,39 +99,5 @@ CORS_ORIGIN_WHITELIST.append("https://{{ ECOMMERCE_HOST }}")
CORS_ORIGIN_WHITELIST.append("https://{{ CREDENTIALS_HOST }}")
{% endif %}


# Dynamic config API settings
# https://openedx.github.io/frontend-platform/module-Config.html
MFE_CONFIG = {
"BASE_URL": "{{ MFE_HOST }}",
"CSRF_TOKEN_API_PATH": "/csrf/api/v1/token",
{%- if MFE_PROFILE_MFE_APP %}
"ACCOUNT_PROFILE_URL": "https://{{ MFE_HOST }}/{{ MFE_PROFILE_MFE_APP["name"] }}",
{%- endif %}
"CREDENTIALS_BASE_URL": "",
"DISCOVERY_API_BASE_URL": "{% if DISCOVERY_HOST is defined %}https://{{ DISCOVERY_HOST }}{% endif %}",
"FAVICON_URL": "https://{{ LMS_HOST }}/favicon.ico",
"LANGUAGE_PREFERENCE_COOKIE_NAME": "openedx-language-preference",
"LMS_BASE_URL": "https://{{ LMS_HOST }}",
"LOGIN_URL": "https://{{ LMS_HOST }}/login",
"LOGO_URL": "https://{{ LMS_HOST }}/theming/asset/images/logo.png",
"LOGO_WHITE_URL": "https://{{ LMS_HOST }}/theming/asset/images/logo.png",
"LOGO_TRADEMARK_URL": "https://{{ LMS_HOST }}/theming/asset/images/logo.png",
"LOGOUT_URL": "https://{{ LMS_HOST }}/logout",
"MARKETING_SITE_BASE_URL": "https://{{ LMS_HOST }}",
"REFRESH_ACCESS_TOKEN_ENDPOINT": "https://{{ LMS_HOST }}/login_refresh",
"SITE_NAME": "{{ PLATFORM_NAME }}",
"STUDIO_BASE_URL": "https://{{ CMS_HOST }}",
"USER_INFO_COOKIE_NAME": "user-info",
"ACCESS_TOKEN_COOKIE_NAME": "edx-jwt-cookie-header-payload",
{%- if MFE_LEARNING_MFE_APP %}
"LEARNING_BASE_URL": "https://{{ MFE_HOST }}/{{ MFE_LEARNING_MFE_APP["name"] }}",
{%- endif %}
{%- if MFE_COURSE_AUTHORING_MFE_APP %}
"ENABLE_NEW_EDITOR_PAGES": True,
"ENABLE_PROGRESS_GRAPH_SETTINGS": True,
{%- endif %}
{%- if MFE_AUTHN_MFE_APP %}
"DISABLE_ENTERPRISE_LOGIN": True,
{%- endif %}
}
{{ patch("mfe-lms-common-settings") }}
{{ patch("mfe-lms-production-settings") }}
126 changes: 72 additions & 54 deletions tutork8s_deploy_tasks/patches/openedx-lms-production-settings
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,89 @@
#
# copied from: https://github.com/overhangio/tutor-mfe/blob/master/tutormfe/patches/openedx-lms-production-settings
#------------------------------------------------------------------------------
{% if MFE_ACCOUNT_MFE_APP %}
ACCOUNT_MICROFRONTEND_URL = "https://{{ MFE_HOST }}/{{ MFE_ACCOUNT_MFE_APP["name"] }}"
{% endif %}
{% if MFE_GRADEBOOK_MFE_APP %}
WRITABLE_GRADEBOOK_URL = "https://{{ MFE_HOST }}/{{ MFE_GRADEBOOK_MFE_APP["name"] }}"
# Dynamic config API settings
# https://openedx.github.io/frontend-platform/module-Config.html
MFE_CONFIG = {
"BASE_URL": "{{ MFE_HOST }}",
"CSRF_TOKEN_API_PATH": "/csrf/api/v1/token",
"CREDENTIALS_BASE_URL": "",
"DISCOVERY_API_BASE_URL": "{% if DISCOVERY_HOST is defined %}{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ DISCOVERY_HOST }}{% endif %}",
"FAVICON_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/favicon.ico",
"INFO_EMAIL": "{{ CONTACT_EMAIL }}",
"LANGUAGE_PREFERENCE_COOKIE_NAME": "openedx-language-preference",
"LMS_BASE_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}",
"LOGIN_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/login",
"LOGO_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/theming/asset/images/logo.png",
"LOGO_WHITE_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/theming/asset/images/logo.png",
"LOGO_TRADEMARK_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/theming/asset/images/logo.png",
"LOGOUT_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/logout",
"MARKETING_SITE_BASE_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}",
"PASSWORD_RESET_SUPPORT_LINK": "mailto:{{ CONTACT_EMAIL }}",
"REFRESH_ACCESS_TOKEN_ENDPOINT": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/login_refresh",
"SITE_NAME": "{{ PLATFORM_NAME }}",
"STUDIO_BASE_URL": "{{ "https" if ENABLE_HTTPS else "http" }}://{{ CMS_HOST }}",
"USER_INFO_COOKIE_NAME": "user-info",
"ACCESS_TOKEN_COOKIE_NAME": "edx-jwt-cookie-header-payload",
}

# MFE-specific settings

{% if get_mfe("authn") %}
AUTHN_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/authn"
AUTHN_MICROFRONTEND_DOMAIN = "{{ MFE_HOST }}/authn"
MFE_CONFIG["DISABLE_ENTERPRISE_LOGIN"] = True
{% endif %}
{% if MFE_LEARNING_MFE_APP %}
LEARNING_MICROFRONTEND_URL = "https://{{ MFE_HOST }}/{{ MFE_LEARNING_MFE_APP["name"] }}"

{% if get_mfe("account") %}
ACCOUNT_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/account/"
MFE_CONFIG["ACCOUNT_SETTINGS_URL"] = ACCOUNT_MICROFRONTEND_URL
{% endif %}
{% if MFE_PROFILE_MFE_APP %}
PROFILE_MICROFRONTEND_URL = "https://{{ MFE_HOST }}/{{ MFE_PROFILE_MFE_APP["name"] }}/u/"

{% if get_mfe("course-authoring") %}
MFE_CONFIG["ENABLE_NEW_EDITOR_PAGES"] = True
MFE_CONFIG["ENABLE_PROGRESS_GRAPH_SETTINGS"] = True
{% endif %}
{% if MFE_DISCUSSIONS_MFE_APP %}
DISCUSSIONS_MICROFRONTEND_URL = "https://{{ MFE_HOST }}/{{ MFE_DISCUSSIONS_MFE_APP["name"] }}"

{% if get_mfe("discussions") %}
DISCUSSIONS_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/discussions"
MFE_CONFIG["DISCUSSIONS_MFE_BASE_URL"] = DISCUSSIONS_MICROFRONTEND_URL
DISCUSSIONS_MFE_FEEDBACK_URL = None
{% endif %}

{% if MFE_AUTHN_MFE_APP %}
AUTHN_MICROFRONTEND_URL = "https://{{ MFE_HOST }}/{{ MFE_AUTHN_MFE_APP["name"] }}"
AUTHN_MICROFRONTEND_DOMAIN = "{{ MFE_HOST }}/{{ MFE_AUTHN_MFE_APP["name"] }}"
{% if get_mfe("gradebook") %}
WRITABLE_GRADEBOOK_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/gradebook"
{% endif %}

{% if get_mfe("learner-dashboard") %}
LEARNER_HOME_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/learner-dashboard/"
{% endif %}

{% if get_mfe("learning") %}
LEARNING_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/learning"
MFE_CONFIG["LEARNING_BASE_URL"] = "{{ "https" if ENABLE_HTTPS else "http" }}://{{ MFE_HOST }}/learning"
{% endif %}

{% if get_mfe("ora-grading") %}
ORA_GRADING_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/ora-grading"
{% endif %}

{% if get_mfe("profile") %}
PROFILE_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/profile/u/"
MFE_CONFIG["ACCOUNT_PROFILE_URL"] = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/profile"
{% endif %}

{% if get_mfe("communications") %}
COMMUNICATIONS_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/communications"
MFE_CONFIG["SCHEDULE_EMAIL_SECTION"] = True
{% endif %}

LOGIN_REDIRECT_WHITELIST.append("{{ MFE_HOST }}")
CSRF_TRUSTED_ORIGINS.append("{{ MFE_HOST }}")
CORS_ORIGIN_WHITELIST.append("{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}")
CSRF_TRUSTED_ORIGINS.append("{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}")

# add missing CORS_ORIGIN_WHITELIST hosts
CORS_ORIGIN_WHITELIST.append("https://{{ LMS_HOST }}")
CORS_ORIGIN_WHITELIST.append("https://{{ CMS_HOST }}")
{% if MFE_HOST is defined %}
CORS_ORIGIN_WHITELIST.append("https://{{ MFE_HOST }}")
{% endif %}
{% if DISCOVERY_HOST is defined %}
CORS_ORIGIN_WHITELIST.append("https://{{ DISCOVERY_HOST }}")
{% endif %}
Expand All @@ -47,39 +99,5 @@ CORS_ORIGIN_WHITELIST.append("https://{{ ECOMMERCE_HOST }}")
CORS_ORIGIN_WHITELIST.append("https://{{ CREDENTIALS_HOST }}")
{% endif %}


# Dynamic config API settings
# https://openedx.github.io/frontend-platform/module-Config.html
MFE_CONFIG = {
"BASE_URL": "{{ MFE_HOST }}",
"CSRF_TOKEN_API_PATH": "/csrf/api/v1/token",
{%- if MFE_PROFILE_MFE_APP %}
"ACCOUNT_PROFILE_URL": "https://{{ MFE_HOST }}/{{ MFE_PROFILE_MFE_APP["name"] }}",
{%- endif %}
"CREDENTIALS_BASE_URL": "",
"DISCOVERY_API_BASE_URL": "{% if DISCOVERY_HOST is defined %}https://{{ DISCOVERY_HOST }}{% endif %}",
"FAVICON_URL": "https://{{ LMS_HOST }}/favicon.ico",
"LANGUAGE_PREFERENCE_COOKIE_NAME": "openedx-language-preference",
"LMS_BASE_URL": "https://{{ LMS_HOST }}",
"LOGIN_URL": "https://{{ LMS_HOST }}/login",
"LOGO_URL": "https://{{ LMS_HOST }}/theming/asset/images/logo.png",
"LOGO_WHITE_URL": "https://{{ LMS_HOST }}/theming/asset/images/logo.png",
"LOGO_TRADEMARK_URL": "https://{{ LMS_HOST }}/theming/asset/images/logo.png",
"LOGOUT_URL": "https://{{ LMS_HOST }}/logout",
"MARKETING_SITE_BASE_URL": "https://{{ LMS_HOST }}",
"REFRESH_ACCESS_TOKEN_ENDPOINT": "https://{{ LMS_HOST }}/login_refresh",
"SITE_NAME": "{{ PLATFORM_NAME }}",
"STUDIO_BASE_URL": "https://{{ CMS_HOST }}",
"USER_INFO_COOKIE_NAME": "user-info",
"ACCESS_TOKEN_COOKIE_NAME": "edx-jwt-cookie-header-payload",
{%- if MFE_LEARNING_MFE_APP %}
"LEARNING_BASE_URL": "https://{{ MFE_HOST }}/{{ MFE_LEARNING_MFE_APP["name"] }}",
{%- endif %}
{%- if MFE_COURSE_AUTHORING_MFE_APP %}
"ENABLE_NEW_EDITOR_PAGES": True,
"ENABLE_PROGRESS_GRAPH_SETTINGS": True,
{%- endif %}
{%- if MFE_AUTHN_MFE_APP %}
"DISABLE_ENTERPRISE_LOGIN": True,
{%- endif %}
}
{{ patch("mfe-lms-common-settings") }}
{{ patch("mfe-lms-production-settings") }}

0 comments on commit 0923d14

Please sign in to comment.