Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ Decision
********

- A lightweight API will be created that returns the mfe configuration variables from the site configuration or django settings. `PR Discussion about django settings`_
- The API will be enabled or disabled using the setting ``ENABLE_MFE_CONFIG_API``.
- The API will always be available. It was originally gated behind an
``ENABLE_MFE_CONFIG_API`` toggle that defaulted to ``False``; that toggle was
removed by the `DEPR ticket for ENABLE_MFE_CONFIG_API`_ because the API only exposes
non-sensitive frontend configuration and returns nothing that an operator has
not explicitly configured.
- The API will take the mfe configuration in the ``MFE_CONFIG`` keyset in the site configuration (admin > site configuration > your domain) or in django settings.
- This API allows to consult the configurations by specific MFE. Making a request like ``/api/mfe_config/v1?mfe=mymfe`` will return the configuration defined in ``MFE_CONFIG_OVERRIDES["mymfe"]`` merged with the ``MFE_CONFIG`` configuration.
- The API will have a mechanism to cache the response with ``MFE_CONFIG_API_CACHE_TIMEOUT`` variable.
Expand Down Expand Up @@ -70,3 +74,5 @@ References
.. _Issue MFE runtime configuration in frontend-wg: https://github.com/openedx/frontend-wg/issues/103

.. _PR Discussion about django settings: https://github.com/openedx/edx-platform/pull/30473#discussion_r916263245

.. _DEPR ticket for ENABLE_MFE_CONFIG_API: https://github.com/openedx/openedx-platform/issues/38959
19 changes: 0 additions & 19 deletions lms/djangoapps/mfe_config_api/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,6 @@ def test_get_mfe_config_with_queryparam_from_django_settings(self):
expected = default_legacy_config | settings.MFE_CONFIG | settings.MFE_CONFIG_OVERRIDES["mymfe"]
self.assertEqual(response.json(), expected) # noqa: PT009

@patch("lms.djangoapps.mfe_config_api.views.configuration_helpers")
@override_settings(ENABLE_MFE_CONFIG_API=False)
def test_404_get_mfe_config(self, configuration_helpers_mock):
"""Test the 404 not found response from get mfe config.

Expected result:
- The get_value method of configuration_helpers is not called.
- The status of the response of the request is a HTTP_404_NOT_FOUND.
"""
response = self.client.get(self.mfe_config_api_url)
configuration_helpers_mock.get_value.assert_not_called()
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) # noqa: PT009

@patch("lms.djangoapps.mfe_config_api.views.configuration_helpers")
def test_get_mfe_config_for_catalog(self, configuration_helpers_mock):
"""Test the mfe config by explicitly using catalog mfe as an example.
Expand Down Expand Up @@ -488,12 +475,6 @@ def setUp(self):
cache.clear()
return super().setUp()

@override_settings(ENABLE_MFE_CONFIG_API=False)
def test_404_when_disabled(self):
"""API returns 404 when ENABLE_MFE_CONFIG_API is False."""
response = self.client.get(self.url)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) # noqa: PT009

@patch("lms.djangoapps.mfe_config_api.views.configuration_helpers")
def test_site_level_keys_translated(self, configuration_helpers_mock):
"""Keys that map to RequiredSiteConfig/OptionalSiteConfig appear at the top level in camelCase."""
Expand Down
9 changes: 1 addition & 8 deletions lms/djangoapps/mfe_config_api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@

import edx_api_doc_tools as apidocs
from django.conf import settings
from django.http import HttpResponseNotFound, JsonResponse
from django.http import JsonResponse
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page
from help_tokens.core import HelpUrlExpert
from rest_framework import status
from rest_framework.exceptions import NotFound
from rest_framework.permissions import AllowAny
from rest_framework.response import Response
from rest_framework.views import APIView
Expand Down Expand Up @@ -299,9 +298,6 @@ def get(self, request):
```
"""

if not settings.ENABLE_MFE_CONFIG_API:
return HttpResponseNotFound()

mfe_name = (
str(request.query_params.get("mfe"))
if request.query_params.get("mfe")
Expand Down Expand Up @@ -438,9 +434,6 @@ def get(self, request):
}
```
"""
if not settings.ENABLE_MFE_CONFIG_API:
raise NotFound()

# Legacy translation (removable once MFE_CONFIG is deprecated).
site_config = translate_legacy_mfe_config()

Expand Down
12 changes: 0 additions & 12 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3066,18 +3066,6 @@
FINANCIAL_ASSISTANCE_APPLICATION_STATUS_URL = "/core/api/financial_assistance_application/status/"
CREATE_FINANCIAL_ASSISTANCE_APPLICATION_URL = '/core/api/financial_assistance_applications'

# .. toggle_name: ENABLE_MFE_CONFIG_API
# .. toggle_implementation: DjangoSetting
# .. toggle_default: False
# .. toggle_description: Set to True to enable MFE Config API. This is disabled by
# default.
# .. toggle_use_cases: open_edx
# .. toggle_creation_date: 2022-05-20
# .. toggle_target_removal_date: None
# .. toggle_warnings: None
# .. toggle_tickets: None
ENABLE_MFE_CONFIG_API = False

# .. setting_name: MFE_CONFIG
# .. setting_implementation: DjangoSetting
# .. setting_default: {}
Expand Down
1 change: 0 additions & 1 deletion lms/envs/mock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ ENABLE_AUTHN_RESET_PASSWORD_HIBP_POLICY: true
ENABLE_COMPREHENSIVE_THEMING: true
ENABLE_COPPA_COMPLIANCE: true
ENABLE_DYNAMIC_REGISTRATION_FIELDS: true
ENABLE_MFE_CONFIG_API: true
ENTERPRISE_ADMIN_PORTAL_BASE_URL: hello
ENTERPRISE_ADMIN_PORTAL_HOSTNAME: hello
ENTERPRISE_ALL_SERVICE_USERNAMES:
Expand Down
1 change: 0 additions & 1 deletion lms/envs/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@
CORS_ORIGIN_WHITELIST = ['https://sandbox.edx.org']

################## MFE API ####################
ENABLE_MFE_CONFIG_API = True
MFE_CONFIG = {
"BASE_URL": "https://name_of_mfe.example.com",
"LANGUAGE_PREFERENCE_COOKIE_NAME": "example-language-preference",
Expand Down
Loading