Added a configuration flag to force third party auth (#24789)
This adds a toggle to allow operators to prevent user registration and login via username/password authentication, forcing the platform to only support login and registration using third-party auth such as SAML. Co-authored-by: Umar Asghar <mrumarasghar@gmail.com>
This commit is contained in:
@@ -193,6 +193,21 @@
|
||||
expect($('.button-oa2-facebook')).toBeVisible();
|
||||
});
|
||||
|
||||
it('does not display the login form', function() {
|
||||
var thirdPartyAuthView = new LoginView({
|
||||
fields: FORM_DESCRIPTION.fields,
|
||||
model: model,
|
||||
resetModel: resetModel,
|
||||
thirdPartyAuth: THIRD_PARTY_AUTH,
|
||||
platformName: PLATFORM_NAME,
|
||||
enterpriseSlugLoginURL: ENTERPRISE_SLUG_LOGIN_URL,
|
||||
is_require_third_party_auth_enabled: true
|
||||
});
|
||||
|
||||
expect(thirdPartyAuthView).not.toContain(view.$submitButton);
|
||||
expect(thirdPartyAuthView).not.toContain($('form-field'));
|
||||
});
|
||||
|
||||
it('displays a link to the signin help', function() {
|
||||
createLoginView(this);
|
||||
|
||||
|
||||
@@ -372,6 +372,20 @@
|
||||
expect($('.button-oa2-facebook')).toBeVisible();
|
||||
});
|
||||
|
||||
it('does not display the registration form', function() {
|
||||
var thirdPartyAuthView = new RegisterView({
|
||||
fields: FORM_DESCRIPTION.fields,
|
||||
model: model,
|
||||
thirdPartyAuth: THIRD_PARTY_AUTH,
|
||||
platformName: PLATFORM_NAME,
|
||||
is_require_third_party_auth_enabled: true
|
||||
});
|
||||
|
||||
expect(thirdPartyAuthView).not.toContain(view.$submitButton);
|
||||
expect(thirdPartyAuthView).not.toContain($('form-field'));
|
||||
});
|
||||
|
||||
|
||||
it('validates registration form fields on form submission', function() {
|
||||
createRegisterView(this);
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
this.isAccountRecoveryFeatureEnabled = options.is_account_recovery_feature_enabled || false;
|
||||
this.isMultipleUserEnterprisesFeatureEnabled =
|
||||
options.is_multiple_user_enterprises_feature_enabled || false;
|
||||
this.is_require_third_party_auth_enabled = options.is_require_third_party_auth_enabled || false;
|
||||
|
||||
// The login view listens for 'sync' events from the reset model
|
||||
this.resetModel = new PasswordResetModel({}, {
|
||||
@@ -162,7 +163,8 @@
|
||||
hideAuthWarnings: this.hideAuthWarnings,
|
||||
pipelineUserDetails: this.pipelineUserDetails,
|
||||
enterpriseName: this.enterpriseName,
|
||||
enterpriseSlugLoginURL: this.enterpriseSlugLoginURL
|
||||
enterpriseSlugLoginURL: this.enterpriseSlugLoginURL,
|
||||
is_require_third_party_auth_enabled: this.is_require_third_party_auth_enabled
|
||||
});
|
||||
|
||||
// Listen for 'password-help' event to toggle sub-views
|
||||
@@ -203,7 +205,8 @@
|
||||
model: model,
|
||||
thirdPartyAuth: this.thirdPartyAuth,
|
||||
platformName: this.platformName,
|
||||
hideAuthWarnings: this.hideAuthWarnings
|
||||
hideAuthWarnings: this.hideAuthWarnings,
|
||||
is_require_third_party_auth_enabled: this.is_require_third_party_auth_enabled
|
||||
});
|
||||
|
||||
// Listen for 'auth-complete' event so we can enroll/redirect the user appropriately.
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
this.pipelineUserDetails = data.pipelineUserDetails;
|
||||
this.enterpriseName = data.enterpriseName;
|
||||
this.enterpriseSlugLoginURL = data.enterpriseSlugLoginURL;
|
||||
this.is_require_third_party_auth_enabled = data.is_require_third_party_auth_enabled || false;
|
||||
|
||||
this.listenTo(this.model, 'sync', this.saveSuccess);
|
||||
this.listenTo(this.resetModel, 'sync', this.resetEmail);
|
||||
@@ -82,7 +83,8 @@
|
||||
platformName: this.platformName,
|
||||
createAccountOption: this.createAccountOption,
|
||||
pipelineUserDetails: this.pipelineUserDetails,
|
||||
enterpriseName: this.enterpriseName
|
||||
enterpriseName: this.enterpriseName,
|
||||
is_require_third_party_auth_enabled: this.is_require_third_party_auth_enabled
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
'terms_of_service'
|
||||
],
|
||||
formType: 'register',
|
||||
formFields: '.form-fields',
|
||||
formStatusTpl: formStatusTpl,
|
||||
authWarningJsHook: 'js-auth-warning',
|
||||
defaultFormErrorsTitle: gettext('We couldn\'t create your account.'),
|
||||
@@ -63,6 +64,7 @@
|
||||
this.autoRegisterWelcomeMessage = data.thirdPartyAuth.autoRegisterWelcomeMessage || '';
|
||||
this.registerFormSubmitButtonText =
|
||||
data.thirdPartyAuth.registerFormSubmitButtonText || _('Create Account');
|
||||
this.is_require_third_party_auth_enabled = data.is_require_third_party_auth_enabled || false;
|
||||
|
||||
this.listenTo(this.model, 'sync', this.saveSuccess);
|
||||
this.listenTo(this.model, 'validation', this.renderLiveValidations);
|
||||
@@ -146,7 +148,8 @@
|
||||
hasSecondaryProviders: this.hasSecondaryProviders,
|
||||
platformName: this.platformName,
|
||||
autoRegisterWelcomeMessage: this.autoRegisterWelcomeMessage,
|
||||
registerFormSubmitButtonText: this.registerFormSubmitButtonText
|
||||
registerFormSubmitButtonText: this.registerFormSubmitButtonText,
|
||||
is_require_third_party_auth_enabled: this.is_require_third_party_auth_enabled
|
||||
}
|
||||
});
|
||||
|
||||
@@ -491,6 +494,7 @@
|
||||
jsHook: this.authWarningJsHook,
|
||||
message: fullMsg
|
||||
});
|
||||
$(this.formFields).removeClass('hidden');
|
||||
},
|
||||
|
||||
submitForm: function(event) { // eslint-disable-line no-unused-vars
|
||||
|
||||
Reference in New Issue
Block a user