From e45b7995290146e3da4e8e21f4778d1ef557fe31 Mon Sep 17 00:00:00 2001 From: melvinsoft Date: Thu, 14 Dec 2017 18:26:24 -0300 Subject: [PATCH 1/2] Add the option of use only SSO login and register --- lms/djangoapps/student_account/views.py | 14 +++++++++++++- lms/envs/aws.py | 2 ++ lms/envs/devstack_appsembler.py | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/student_account/views.py b/lms/djangoapps/student_account/views.py index ae3076d2e24d..f840c5b623f2 100644 --- a/lms/djangoapps/student_account/views.py +++ b/lms/djangoapps/student_account/views.py @@ -102,12 +102,24 @@ def login_and_registration_form(request, initial_mode="login"): except (KeyError, ValueError, IndexError): pass + third_party_auth = _third_party_auth_context(request, redirect_to) + if not third_party_auth['currentProvider'] and settings.APPSEMBLER_FEATURES.get('ENABLE_EXCLUSIVE_SSO_LOGISTRATION'): + urls_dict = configuration_helpers.get_value( + 'EXCLUSIVE_SSO_LOGISTRATION_URL_MAP', + settings.EXCLUSIVE_SSO_LOGISTRATION_URL_MAP) + if initial_mode == 'register': + if 'register' in urls_dict: + return redirect(urls_dict['register']) + elif initial_mode == 'login': + if 'login' in urls_dict: + return redirect(urls_dict['login']) + # Otherwise, render the combined login/registration page context = { 'data': { 'login_redirect_url': redirect_to, 'initial_mode': initial_mode, - 'third_party_auth': _third_party_auth_context(request, redirect_to), + 'third_party_auth': third_party_auth, 'third_party_auth_hint': third_party_auth_hint or '', 'platform_name': configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME), diff --git a/lms/envs/aws.py b/lms/envs/aws.py index 64abde780522..7460a4ceaed5 100644 --- a/lms/envs/aws.py +++ b/lms/envs/aws.py @@ -870,3 +870,5 @@ APP_UPGRADE_CACHE_TIMEOUT = ENV_TOKENS.get('APP_UPGRADE_CACHE_TIMEOUT', APP_UPGRADE_CACHE_TIMEOUT) AFFILIATE_COOKIE_NAME = ENV_TOKENS.get('AFFILIATE_COOKIE_NAME', AFFILIATE_COOKIE_NAME) + +EXCLUSIVE_SSO_LOGISTRATION_URL_MAP = ENV_TOKENS.get('EXCLUSIVE_SSO_LOGISTRATION_URL_MAP', {}) \ No newline at end of file diff --git a/lms/envs/devstack_appsembler.py b/lms/envs/devstack_appsembler.py index 0b17e5118668..f807d8c5e3d2 100644 --- a/lms/envs/devstack_appsembler.py +++ b/lms/envs/devstack_appsembler.py @@ -106,3 +106,5 @@ SP_SAML_RESTRICT_MODE = False CUSTOM_SSO_FIELDS_SYNC = ENV_TOKENS.get('CUSTOM_SSO_FIELDS_SYNC', {}) + +EXCLUSIVE_SSO_LOGISTRATION_URL_MAP = ENV_TOKENS.get('EXCLUSIVE_SSO_LOGISTRATION_URL_MAP', {}) \ No newline at end of file From f8cccea89bd6cb8c83aabe0d3949bcbd6230cedc Mon Sep 17 00:00:00 2001 From: melvinsoft Date: Tue, 19 Dec 2017 21:02:55 -0300 Subject: [PATCH 2/2] unify vars in env files --- lms/envs/aws.py | 2 -- lms/envs/aws_appsembler.py | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lms/envs/aws.py b/lms/envs/aws.py index 7460a4ceaed5..64abde780522 100644 --- a/lms/envs/aws.py +++ b/lms/envs/aws.py @@ -870,5 +870,3 @@ APP_UPGRADE_CACHE_TIMEOUT = ENV_TOKENS.get('APP_UPGRADE_CACHE_TIMEOUT', APP_UPGRADE_CACHE_TIMEOUT) AFFILIATE_COOKIE_NAME = ENV_TOKENS.get('AFFILIATE_COOKIE_NAME', AFFILIATE_COOKIE_NAME) - -EXCLUSIVE_SSO_LOGISTRATION_URL_MAP = ENV_TOKENS.get('EXCLUSIVE_SSO_LOGISTRATION_URL_MAP', {}) \ No newline at end of file diff --git a/lms/envs/aws_appsembler.py b/lms/envs/aws_appsembler.py index 8c3709a6bfc9..258e74b16f61 100644 --- a/lms/envs/aws_appsembler.py +++ b/lms/envs/aws_appsembler.py @@ -114,3 +114,5 @@ CORS_REPLACE_HTTPS_REFERER = True CUSTOM_SSO_FIELDS_SYNC = ENV_TOKENS.get('CUSTOM_SSO_FIELDS_SYNC', {}) + +EXCLUSIVE_SSO_LOGISTRATION_URL_MAP = ENV_TOKENS.get('EXCLUSIVE_SSO_LOGISTRATION_URL_MAP', {}) \ No newline at end of file