fix: making LOGIN_REDIRECT_WHITELIST configurable through env files (#26760)

LOGIN_REDIRECT_WHITELIST has been used to filter redirect-url while processing logout requests but its configurations were not picked through environment files like lms.yml or studio.yml. This PR fixes that bug.
This commit is contained in:
Hamza Farooq
2021-08-03 17:29:23 +05:00
committed by GitHub
parent d6202880ae
commit 4a2549f49a
4 changed files with 20 additions and 4 deletions

View File

@@ -276,8 +276,13 @@ if "TRACKING_IGNORE_URL_PATTERNS" in ENV_TOKENS:
# Heartbeat
HEARTBEAT_CELERY_ROUTING_KEY = ENV_TOKENS.get('HEARTBEAT_CELERY_ROUTING_KEY', HEARTBEAT_CELERY_ROUTING_KEY)
LOGIN_REDIRECT_WHITELIST = [reverse_lazy('home')]
# Sometimes, OAuth2 clients want the user to redirect back to their site after logout. But to determine if the given
# redirect URL/path is safe for redirection, the following variable is used by edX.
LOGIN_REDIRECT_WHITELIST = ENV_TOKENS.get(
'LOGIN_REDIRECT_WHITELIST',
LOGIN_REDIRECT_WHITELIST
)
LOGIN_REDIRECT_WHITELIST.extend([reverse_lazy('home')])
############### XBlock filesystem field config ##########
if 'DJFS' in AUTH_TOKENS and AUTH_TOKENS['DJFS'] is not None:

View File

@@ -3378,6 +3378,10 @@ if FEATURES.get('ENABLE_CORS_HEADERS'):
# to simulate cross-domain requests.
XDOMAIN_PROXY_CACHE_TIMEOUT = 60 * 15
# .. setting_name: LOGIN_REDIRECT_WHITELIST
# .. setting_default: empty list ([])
# .. setting_description: While logout, if logout request has a redirect-url as query strings,
# then the redirect-url is validated through LOGIN_REDIRECT_WHITELIST.
LOGIN_REDIRECT_WHITELIST = []
###################### Registration ##################################

View File

@@ -256,7 +256,7 @@ CORS_ALLOW_HEADERS = corsheaders_default_headers + (
'use-jwt-cookie',
)
LOGIN_REDIRECT_WHITELIST = [
LOGIN_REDIRECT_WHITELIST.extend([
CMS_BASE,
# Allow redirection to all micro-frontends.
# Please add your MFE if is not already listed here.
@@ -272,7 +272,7 @@ LOGIN_REDIRECT_WHITELIST = [
'localhost:18400', # frontend-app-publisher
ENTERPRISE_LEARNER_PORTAL_NETLOC, # frontend-app-learner-portal-enterprise
ENTERPRISE_ADMIN_PORTAL_NETLOC, # frontend-app-admin-portal
]
])
###################### JWTs ######################
JWT_AUTH.update({

View File

@@ -182,6 +182,13 @@ ALLOWED_HOSTS = [
FEATURES['PREVIEW_LMS_BASE'],
]
# Sometimes, OAuth2 clients want the user to redirect back to their site after logout. But to determine if the given
# redirect URL/path is safe for redirection, the following variable is used by edX.
LOGIN_REDIRECT_WHITELIST = ENV_TOKENS.get(
'LOGIN_REDIRECT_WHITELIST',
LOGIN_REDIRECT_WHITELIST
)
# allow for environments to specify what cookie name our login subsystem should use
# this is to fix a bug regarding simultaneous logins between edx.org and edge.edx.org which can
# happen with some browsers (e.g. Firefox)