Introduce LMS_INTERNAL_ROOT_URL.

The LMS and edx-enterprise currently communicate via REST APIs, even
though they are all running within the same service.

Currently API URLs are constructed using LMS_ROOT_URL, but that is
problematic on some systems where the external LMS_ROOT_URL is not
accessible from the private network, or routing internal requests via
the external URL is not desireable.

This patch introduces a new setting variable LMS_INTERNAL_ROOT_URL which
defaults to the value of LMS_ROOT_URL for backwards compatibility.

The LMS and edx-enterprise will use LMS_INTERNAL_ROOT_URL to construct
API URLs instead of LMS_ROOT_URL.
This commit is contained in:
Matjaz Gregoric
2017-11-08 10:15:35 +01:00
parent 705aac7980
commit d403e5f8b1
7 changed files with 22 additions and 14 deletions

View File

@@ -138,6 +138,9 @@ EMAIL_USE_TLS = ENV_TOKENS.get('EMAIL_USE_TLS', EMAIL_USE_TLS)
LMS_BASE = ENV_TOKENS.get('LMS_BASE')
LMS_ROOT_URL = ENV_TOKENS.get('LMS_ROOT_URL')
LMS_INTERNAL_ROOT_URL = ENV_TOKENS.get('LMS_INTERNAL_ROOT_URL', LMS_ROOT_URL)
ENTERPRISE_API_URL = ENV_TOKENS.get('ENTERPRISE_API_URL', LMS_INTERNAL_ROOT_URL + '/enterprise/api/v1/')
ENTERPRISE_CONSENT_API_URL = ENV_TOKENS.get('ENTERPRISE_CONSENT_API_URL', LMS_INTERNAL_ROOT_URL + '/consent/api/v1/')
# Note that FEATURES['PREVIEW_LMS_BASE'] gets read in from the environment file.
SITE_NAME = ENV_TOKENS['SITE_NAME']

View File

@@ -378,9 +378,10 @@ AUTHENTICATION_BACKENDS = [
LMS_BASE = None
LMS_ROOT_URL = "http://localhost:8000"
LMS_INTERNAL_ROOT_URL = LMS_ROOT_URL
LMS_ENROLLMENT_API_PATH = "/api/enrollment/v1/"
ENTERPRISE_API_URL = LMS_ROOT_URL + '/enterprise/api/v1/'
ENTERPRISE_CONSENT_API_URL = LMS_ROOT_URL + '/consent/api/v1/'
ENTERPRISE_API_URL = LMS_INTERNAL_ROOT_URL + '/enterprise/api/v1/'
ENTERPRISE_CONSENT_API_URL = LMS_INTERNAL_ROOT_URL + '/consent/api/v1/'
# These are standard regexes for pulling out info like course_ids, usage_ids, etc.
# They are used so that URLs with deprecated-format strings still work.