ENT-2894: Use new welcome template when redirected from enterprise proxy login view (#24587)
* using new welcome template when redirected from enterprise proxy login view * enabling safe redirects to enterprise learner portal from login in devstack * ading admin portal to login redirect whitelist * running make upgrade to version bump edx-enterprise
This commit is contained in:
@@ -3655,6 +3655,10 @@ ENTERPRISE_SPECIFIC_BRANDED_WELCOME_TEMPLATE = _(
|
||||
u'{line_break}Please note that {platform_name} has a different {privacy_policy_link_start}Privacy Policy'
|
||||
u'{privacy_policy_link_end} from {enterprise_name}.'
|
||||
)
|
||||
ENTERPRISE_PROXY_LOGIN_WELCOME_TEMPLATE = _(
|
||||
u'{start_bold}{enterprise_name}{end_bold} has partnered with {start_bold}{platform_name}{end_bold} '
|
||||
u'to offer you high-quality learning opportunities from the world\'s best institutions and universities.'
|
||||
)
|
||||
ENTERPRISE_TAGLINE = ''
|
||||
ENTERPRISE_EXCLUDED_REGISTRATION_FIELDS = {
|
||||
'age',
|
||||
@@ -3915,9 +3919,6 @@ BLOCKSTORE_API_URL = 'http://localhost:18250/api/v1/'
|
||||
# in the blockstore-based XBlock runtime
|
||||
XBLOCK_RUNTIME_V2_EPHEMERAL_DATA_CACHE = 'default'
|
||||
|
||||
########################## LEARNER PORTAL ##############################
|
||||
LEARNER_PORTAL_URL_ROOT = 'http://localhost:8734'
|
||||
|
||||
######################### MICROSITE ###############################
|
||||
MICROSITE_ROOT_DIR = '/edx/app/edxapp/edx-microsite'
|
||||
MICROSITE_CONFIGURATION = {}
|
||||
|
||||
@@ -251,6 +251,17 @@ CREDENTIALS_PUBLIC_SERVICE_URL = 'http://localhost:18150'
|
||||
############################### BLOCKSTORE #####################################
|
||||
BLOCKSTORE_API_URL = "http://edx.devstack.blockstore:18250/api/v1/"
|
||||
|
||||
########################## PROGRAMS LEARNER PORTAL ##############################
|
||||
LEARNER_PORTAL_URL_ROOT = 'http://localhost:8734'
|
||||
|
||||
########################## ENTERPRISE LEARNER PORTAL ##############################
|
||||
ENTERPRISE_LEARNER_PORTAL_NETLOC = 'localhost:8734'
|
||||
ENTERPRISE_LEARNER_PORTAL_BASE_URL = 'http://' + ENTERPRISE_LEARNER_PORTAL_NETLOC
|
||||
|
||||
########################## ENTERPRISE ADMIN PORTAL ##############################
|
||||
ENTERPRISE_ADMIN_PORTAL_NETLOC = 'localhost:1991'
|
||||
ENTERPRISE_ADMIN_PORTAL_BASE_URL = 'http://' + ENTERPRISE_ADMIN_PORTAL_NETLOC
|
||||
|
||||
###################### Cross-domain requests ######################
|
||||
FEATURES['ENABLE_CORS_HEADERS'] = True
|
||||
CORS_ALLOW_CREDENTIALS = True
|
||||
@@ -260,7 +271,11 @@ CORS_ALLOW_HEADERS = corsheaders_default_headers + (
|
||||
'use-jwt-cookie',
|
||||
)
|
||||
|
||||
LOGIN_REDIRECT_WHITELIST = [CMS_BASE]
|
||||
LOGIN_REDIRECT_WHITELIST = [
|
||||
CMS_BASE,
|
||||
ENTERPRISE_LEARNER_PORTAL_NETLOC,
|
||||
ENTERPRISE_ADMIN_PORTAL_NETLOC,
|
||||
]
|
||||
|
||||
###################### JWTs ######################
|
||||
JWT_AUTH.update({
|
||||
@@ -360,8 +375,6 @@ MKTG_URLS = {
|
||||
'WHAT_IS_VERIFIED_CERT': '/verified-certificate',
|
||||
}
|
||||
|
||||
ENTERPRISE_LEARNER_PORTAL_BASE_URL = 'http://localhost:8734'
|
||||
|
||||
ENTERPRISE_MARKETING_FOOTER_QUERY_PARAMS = {}
|
||||
|
||||
CREDENTIALS_SERVICE_USERNAME = 'credentials_worker'
|
||||
|
||||
@@ -500,6 +500,9 @@ FRONTEND_LOGIN_URL = '/login'
|
||||
FRONTEND_LOGOUT_URL = '/logout'
|
||||
FRONTEND_REGISTER_URL = '/register'
|
||||
|
||||
# Programs Learner Portal URL
|
||||
LEARNER_PORTAL_URL_ROOT = 'http://localhost:8734'
|
||||
|
||||
ECOMMERCE_API_URL = 'https://ecommerce.example.com/api/v2/'
|
||||
ECOMMERCE_PUBLIC_URL_ROOT = None
|
||||
ENTERPRISE_API_URL = 'http://enterprise.example.com/enterprise/api/v1/'
|
||||
|
||||
@@ -232,7 +232,6 @@ def login_and_registration_form(request, initial_mode="login"):
|
||||
settings.FEATURES['ENABLE_COMBINED_LOGIN_REGISTRATION_FOOTER']
|
||||
),
|
||||
}
|
||||
|
||||
enterprise_customer = enterprise_customer_for_request(request)
|
||||
update_logistration_context_for_enterprise(request, context, enterprise_customer)
|
||||
|
||||
|
||||
@@ -424,15 +424,17 @@ class LoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMixin, ModuleSto
|
||||
|
||||
@mock.patch('openedx.core.djangoapps.user_authn.views.login_form.enterprise_customer_for_request')
|
||||
@ddt.data(
|
||||
('signin_user', False, None, None),
|
||||
('register_user', False, None, None),
|
||||
('signin_user', True, 'Fake EC', 'http://logo.com/logo.jpg'),
|
||||
('register_user', True, 'Fake EC', 'http://logo.com/logo.jpg'),
|
||||
('signin_user', True, 'Fake EC', None),
|
||||
('register_user', True, 'Fake EC', None),
|
||||
('signin_user', False, None, None, False),
|
||||
('register_user', False, None, None, False),
|
||||
('signin_user', True, 'Fake EC', 'http://logo.com/logo.jpg', False),
|
||||
('register_user', True, 'Fake EC', 'http://logo.com/logo.jpg', False),
|
||||
('signin_user', True, 'Fake EC', 'http://logo.com/logo.jpg', True),
|
||||
('register_user', True, 'Fake EC', 'http://logo.com/logo.jpg', True),
|
||||
('signin_user', True, 'Fake EC', None, False),
|
||||
('register_user', True, 'Fake EC', None, False),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_enterprise_register(self, url_name, ec_present, ec_name, logo_url, mock_get_ec):
|
||||
def test_enterprise_register(self, url_name, ec_present, ec_name, logo_url, is_proxy, mock_get_ec):
|
||||
"""
|
||||
Verify that when an EnterpriseCustomer is received on the login and register views,
|
||||
the appropriate sidebar is rendered.
|
||||
@@ -445,7 +447,11 @@ class LoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMixin, ModuleSto
|
||||
else:
|
||||
mock_get_ec.return_value = None
|
||||
|
||||
response = self.client.get(reverse(url_name), HTTP_ACCEPT="text/html")
|
||||
params = []
|
||||
if is_proxy:
|
||||
params.append(("proxy_login", "True"))
|
||||
|
||||
response = self.client.get(reverse(url_name), params, HTTP_ACCEPT="text/html")
|
||||
|
||||
enterprise_sidebar_div_id = u'enterprise-content-container'
|
||||
|
||||
@@ -453,7 +459,10 @@ class LoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMixin, ModuleSto
|
||||
self.assertNotContains(response, text=enterprise_sidebar_div_id)
|
||||
else:
|
||||
self.assertContains(response, text=enterprise_sidebar_div_id)
|
||||
welcome_message = settings.ENTERPRISE_SPECIFIC_BRANDED_WELCOME_TEMPLATE
|
||||
if is_proxy:
|
||||
welcome_message = settings.ENTERPRISE_PROXY_LOGIN_WELCOME_TEMPLATE
|
||||
else:
|
||||
welcome_message = settings.ENTERPRISE_SPECIFIC_BRANDED_WELCOME_TEMPLATE
|
||||
expected_message = Text(welcome_message).format(
|
||||
start_bold=HTML('<b>'),
|
||||
end_bold=HTML('</b>'),
|
||||
|
||||
@@ -450,7 +450,7 @@ def enterprise_customer_for_request(request):
|
||||
Check all the context clues of the request to determine if
|
||||
the request being made is tied to a particular EnterpriseCustomer.
|
||||
"""
|
||||
if 'enterprise_customer' in request.session:
|
||||
if 'enterprise_customer' in request.session and request.session['enterprise_customer']:
|
||||
return enterprise_customer_from_cache(request=request)
|
||||
else:
|
||||
enterprise_customer = enterprise_customer_from_api(request)
|
||||
|
||||
@@ -51,7 +51,8 @@ def update_logistration_context_for_enterprise(request, context, enterprise_cust
|
||||
"""
|
||||
sidebar_context = {}
|
||||
if enterprise_customer:
|
||||
sidebar_context = get_enterprise_sidebar_context(enterprise_customer)
|
||||
is_proxy_login = request.GET.get('proxy_login')
|
||||
sidebar_context = get_enterprise_sidebar_context(enterprise_customer, is_proxy_login)
|
||||
|
||||
if sidebar_context:
|
||||
context['data']['registration_form_desc']['fields'] = enterprise_fields_only(
|
||||
@@ -67,7 +68,7 @@ def update_logistration_context_for_enterprise(request, context, enterprise_cust
|
||||
update_third_party_auth_context_for_enterprise(request, context, enterprise_customer)
|
||||
|
||||
|
||||
def get_enterprise_sidebar_context(enterprise_customer):
|
||||
def get_enterprise_sidebar_context(enterprise_customer, is_proxy_login):
|
||||
"""
|
||||
Get context information for enterprise sidebar for the given enterprise customer.
|
||||
|
||||
@@ -84,10 +85,16 @@ def get_enterprise_sidebar_context(enterprise_customer):
|
||||
branding_configuration = enterprise_customer.get('branding_configuration', {})
|
||||
logo_url = branding_configuration.get('logo', '') if isinstance(branding_configuration, dict) else ''
|
||||
|
||||
branded_welcome_template = configuration_helpers.get_value(
|
||||
'ENTERPRISE_SPECIFIC_BRANDED_WELCOME_TEMPLATE',
|
||||
settings.ENTERPRISE_SPECIFIC_BRANDED_WELCOME_TEMPLATE
|
||||
)
|
||||
if is_proxy_login:
|
||||
branded_welcome_template = configuration_helpers.get_value(
|
||||
'ENTERPRISE_PROXY_LOGIN_WELCOME_TEMPLATE',
|
||||
settings.ENTERPRISE_PROXY_LOGIN_WELCOME_TEMPLATE
|
||||
)
|
||||
else:
|
||||
branded_welcome_template = configuration_helpers.get_value(
|
||||
'ENTERPRISE_SPECIFIC_BRANDED_WELCOME_TEMPLATE',
|
||||
settings.ENTERPRISE_SPECIFIC_BRANDED_WELCOME_TEMPLATE
|
||||
)
|
||||
|
||||
branded_welcome_string = Text(branded_welcome_template).format(
|
||||
start_bold=HTML('<b>'),
|
||||
|
||||
@@ -40,7 +40,7 @@ drf-yasg<1.17.1
|
||||
# The team that owns this package will manually bump this package rather than having it pulled in automatically.
|
||||
# This is to allow them to better control its deployment and to do it in a process that works better
|
||||
# for them.
|
||||
edx-enterprise==3.4.27
|
||||
edx-enterprise==3.4.28
|
||||
|
||||
# Upgrading to 2.12.0 breaks several test classes due to API changes, need to update our code accordingly
|
||||
factory-boy==2.8.1
|
||||
|
||||
@@ -99,7 +99,7 @@ edx-django-release-util==0.4.4 # via -r requirements/edx/base.in
|
||||
edx-django-sites-extensions==2.5.1 # via -r requirements/edx/base.in
|
||||
edx-django-utils==3.5.0 # via -r requirements/edx/base.in, django-config-models, edx-drf-extensions, edx-enterprise, edx-rest-api-client, edx-when
|
||||
edx-drf-extensions==6.1.1 # via -r requirements/edx/base.in, edx-completion, edx-enterprise, edx-organizations, edx-proctoring, edx-rbac, edx-when, edxval
|
||||
edx-enterprise==3.4.27 # via -c requirements/edx/../constraints.txt, -r requirements/edx/base.in
|
||||
edx-enterprise==3.4.28 # via -c requirements/edx/../constraints.txt, -r requirements/edx/base.in
|
||||
edx-i18n-tools==0.5.3 # via ora2
|
||||
edx-milestones==0.3.0 # via -r requirements/edx/base.in
|
||||
edx-opaque-keys[django]==2.1.1 # via -r requirements/edx/paver.txt, edx-bulk-grades, edx-ccx-keys, edx-completion, edx-drf-extensions, edx-enterprise, edx-milestones, edx-organizations, edx-proctoring, edx-user-state-client, edx-when, xmodule
|
||||
@@ -165,7 +165,7 @@ nodeenv==1.4.0 # via -r requirements/edx/base.in
|
||||
numpy==1.18.5 # via -c requirements/edx/../constraints.txt, chem, openedx-calc, scipy
|
||||
oauthlib==3.0.1 # via -c requirements/edx/../constraints.txt, -r requirements/edx/base.in, django-oauth-toolkit, lti-consumer-xblock, requests-oauthlib, social-auth-core
|
||||
openedx-calc==1.0.9 # via -r requirements/edx/base.in
|
||||
ora2==2.8.8 # via -r requirements/edx/base.in
|
||||
ora2==2.8.9 # via -r requirements/edx/base.in
|
||||
packaging==20.4 # via bleach, drf-yasg
|
||||
path.py==12.4.0 # via edx-enterprise, edx-i18n-tools, ora2, xmodule
|
||||
path==13.1.0 # via -c requirements/edx/../constraints.txt, -r requirements/edx/paver.txt, path.py
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# make upgrade
|
||||
#
|
||||
coverage==5.2 # via -r requirements/edx/coverage.in
|
||||
coverage==5.2.1 # via -r requirements/edx/coverage.in
|
||||
diff-cover==3.0.1 # via -r requirements/edx/coverage.in
|
||||
importlib-metadata==1.7.0 # via inflect, pluggy
|
||||
inflect==3.0.2 # via -c requirements/edx/../constraints.txt, jinja2-pluralize
|
||||
|
||||
@@ -48,7 +48,7 @@ colorama==0.4.1 # via -r requirements/edx/testing.txt, radon
|
||||
contextlib2==0.6.0.post1 # via -r requirements/edx/testing.txt
|
||||
coreapi==2.3.3 # via -r requirements/edx/testing.txt, drf-yasg
|
||||
coreschema==0.0.4 # via -r requirements/edx/testing.txt, coreapi, drf-yasg
|
||||
coverage==5.2 # via -r requirements/edx/testing.txt, pytest-cov
|
||||
coverage==5.2.1 # via -r requirements/edx/testing.txt, pytest-cov
|
||||
git+https://github.com/nedbat/coverage_pytest_plugin.git@29de030251471e200ff255eb9e549218cd60e872#egg=coverage_pytest_plugin==0.0 # via -r requirements/edx/testing.txt
|
||||
crowdsourcehinter-xblock==0.6 # via -r requirements/edx/testing.txt
|
||||
cryptography==3.0 # via -r requirements/edx/testing.txt, django-fernet-fields, edx-enterprise, pdfminer.six, pyjwt, social-auth-core
|
||||
@@ -111,7 +111,7 @@ edx-django-release-util==0.4.4 # via -r requirements/edx/testing.txt
|
||||
edx-django-sites-extensions==2.5.1 # via -r requirements/edx/testing.txt
|
||||
edx-django-utils==3.5.0 # via -r requirements/edx/testing.txt, django-config-models, edx-drf-extensions, edx-enterprise, edx-rest-api-client, edx-when
|
||||
edx-drf-extensions==6.1.1 # via -r requirements/edx/testing.txt, edx-completion, edx-enterprise, edx-organizations, edx-proctoring, edx-rbac, edx-when, edxval
|
||||
edx-enterprise==3.4.27 # via -c requirements/edx/../constraints.txt, -r requirements/edx/testing.txt
|
||||
edx-enterprise==3.4.28 # via -c requirements/edx/../constraints.txt, -r requirements/edx/testing.txt
|
||||
edx-i18n-tools==0.5.3 # via -r requirements/edx/testing.txt, ora2
|
||||
edx-lint==1.5.0 # via -r requirements/edx/testing.txt
|
||||
edx-milestones==0.3.0 # via -r requirements/edx/testing.txt
|
||||
@@ -200,7 +200,7 @@ nodeenv==1.4.0 # via -r requirements/edx/testing.txt
|
||||
numpy==1.18.5 # via -c requirements/edx/../constraints.txt, -r requirements/edx/testing.txt, chem, openedx-calc, scipy
|
||||
oauthlib==3.0.1 # via -c requirements/edx/../constraints.txt, -r requirements/edx/testing.txt, django-oauth-toolkit, lti-consumer-xblock, requests-oauthlib, social-auth-core
|
||||
openedx-calc==1.0.9 # via -r requirements/edx/testing.txt
|
||||
ora2==2.8.8 # via -r requirements/edx/testing.txt
|
||||
ora2==2.8.9 # via -r requirements/edx/testing.txt
|
||||
packaging==20.4 # via -r requirements/edx/testing.txt, bleach, drf-yasg, pytest, sphinx, tox
|
||||
path.py==12.4.0 # via -r requirements/edx/testing.txt, edx-enterprise, edx-i18n-tools, ora2, xmodule
|
||||
path==13.1.0 # via -c requirements/edx/../constraints.txt, -r requirements/edx/testing.txt, path.py
|
||||
@@ -314,7 +314,7 @@ unidiff==0.6.0 # via -r requirements/edx/testing.txt, coverage-pytest
|
||||
uritemplate==3.0.1 # via -r requirements/edx/testing.txt, coreapi, drf-yasg
|
||||
urllib3==1.25.10 # via -r requirements/edx/testing.txt, elasticsearch, geoip2, requests, selenium, transifex-client
|
||||
user-util==0.2 # via -r requirements/edx/testing.txt
|
||||
virtualenv==20.0.27 # via -r requirements/edx/testing.txt, tox
|
||||
virtualenv==20.0.28 # via -r requirements/edx/testing.txt, tox
|
||||
voluptuous==0.11.7 # via -r requirements/edx/testing.txt, ora2
|
||||
vulture==1.5 # via -r requirements/edx/development.in
|
||||
watchdog==0.10.3 # via -r requirements/edx/testing.txt
|
||||
|
||||
@@ -47,7 +47,7 @@ colorama==0.4.1 # via radon
|
||||
contextlib2==0.6.0.post1 # via -r requirements/edx/base.txt
|
||||
coreapi==2.3.3 # via -r requirements/edx/base.txt, drf-yasg
|
||||
coreschema==0.0.4 # via -r requirements/edx/base.txt, coreapi, drf-yasg
|
||||
coverage==5.2 # via -r requirements/edx/coverage.txt, pytest-cov
|
||||
coverage==5.2.1 # via -r requirements/edx/coverage.txt, pytest-cov
|
||||
git+https://github.com/nedbat/coverage_pytest_plugin.git@29de030251471e200ff255eb9e549218cd60e872#egg=coverage_pytest_plugin==0.0 # via -r requirements/edx/testing.in
|
||||
crowdsourcehinter-xblock==0.6 # via -r requirements/edx/base.txt
|
||||
cryptography==3.0 # via -r requirements/edx/base.txt, django-fernet-fields, edx-enterprise, pdfminer.six, pyjwt, social-auth-core
|
||||
@@ -108,7 +108,7 @@ edx-django-release-util==0.4.4 # via -r requirements/edx/base.txt
|
||||
edx-django-sites-extensions==2.5.1 # via -r requirements/edx/base.txt
|
||||
edx-django-utils==3.5.0 # via -r requirements/edx/base.txt, django-config-models, edx-drf-extensions, edx-enterprise, edx-rest-api-client, edx-when
|
||||
edx-drf-extensions==6.1.1 # via -r requirements/edx/base.txt, edx-completion, edx-enterprise, edx-organizations, edx-proctoring, edx-rbac, edx-when, edxval
|
||||
edx-enterprise==3.4.27 # via -c requirements/edx/../constraints.txt, -r requirements/edx/base.txt
|
||||
edx-enterprise==3.4.28 # via -c requirements/edx/../constraints.txt, -r requirements/edx/base.txt
|
||||
edx-i18n-tools==0.5.3 # via -r requirements/edx/base.txt, -r requirements/edx/testing.in, ora2
|
||||
edx-lint==1.5.0 # via -r requirements/edx/testing.in
|
||||
edx-milestones==0.3.0 # via -r requirements/edx/base.txt
|
||||
@@ -192,7 +192,7 @@ nodeenv==1.4.0 # via -r requirements/edx/base.txt
|
||||
numpy==1.18.5 # via -c requirements/edx/../constraints.txt, -r requirements/edx/base.txt, chem, openedx-calc, scipy
|
||||
oauthlib==3.0.1 # via -c requirements/edx/../constraints.txt, -r requirements/edx/base.txt, django-oauth-toolkit, lti-consumer-xblock, requests-oauthlib, social-auth-core
|
||||
openedx-calc==1.0.9 # via -r requirements/edx/base.txt
|
||||
ora2==2.8.8 # via -r requirements/edx/base.txt
|
||||
ora2==2.8.9 # via -r requirements/edx/base.txt
|
||||
packaging==20.4 # via -r requirements/edx/base.txt, bleach, drf-yasg, pytest, tox
|
||||
path.py==12.4.0 # via -r requirements/edx/base.txt, edx-enterprise, edx-i18n-tools, ora2, xmodule
|
||||
path==13.1.0 # via -c requirements/edx/../constraints.txt, -r requirements/edx/base.txt, path.py
|
||||
@@ -293,7 +293,7 @@ unidiff==0.6.0 # via -r requirements/edx/testing.in, coverage-pytest-
|
||||
uritemplate==3.0.1 # via -r requirements/edx/base.txt, coreapi, drf-yasg
|
||||
urllib3==1.25.10 # via -r requirements/edx/base.txt, elasticsearch, geoip2, requests, selenium, transifex-client
|
||||
user-util==0.2 # via -r requirements/edx/base.txt
|
||||
virtualenv==20.0.27 # via tox
|
||||
virtualenv==20.0.28 # via tox
|
||||
voluptuous==0.11.7 # via -r requirements/edx/base.txt, ora2
|
||||
watchdog==0.10.3 # via -r requirements/edx/base.txt
|
||||
wcwidth==0.2.5 # via pytest
|
||||
|
||||
Reference in New Issue
Block a user