diff --git a/app/assets/javascripts/admin/addon/controllers/admin-user-index.js b/app/assets/javascripts/admin/addon/controllers/admin-user-index.js index cfc0cd8c880..cea12a54167 100644 --- a/app/assets/javascripts/admin/addon/controllers/admin-user-index.js +++ b/app/assets/javascripts/admin/addon/controllers/admin-user-index.js @@ -590,7 +590,7 @@ export default Controller.extend(CanCheckEmails, { deleteSSORecord() { return bootbox.confirm( - I18n.t("admin.user.sso.confirm_delete"), + I18n.t("admin.user.discourse_connect.confirm_delete"), I18n.t("no_value"), I18n.t("yes_value"), (confirmed) => { diff --git a/app/assets/javascripts/admin/addon/templates/user-index.hbs b/app/assets/javascripts/admin/addon/templates/user-index.hbs index cc25a5b0cab..4ac76fb01df 100644 --- a/app/assets/javascripts/admin/addon/templates/user-index.hbs +++ b/app/assets/javascripts/admin/addon/templates/user-index.hbs @@ -70,8 +70,8 @@ {{/if}}
You’re almost done! We sent an activation mail to your email address. Please follow the instructions in the mail to activate your account.
If it doesn’t arrive, check your spam folder.
" cant_invite_to_group: "You are not allowed to invite users to specified group(s). Make sure you are owner of the group(s) you are trying to invite to." disabled_errors: - sso_enabled: "Invites are disabled because SSO is enabled." + discourse_connect_enabled: "Invites are disabled because DiscourseConnect is enabled." local_logins_disabled: "Invites are disabled because the 'enable local logins' setting is disabled." invalid_access: "You are not permitted to view the requested resource." @@ -448,7 +448,7 @@ en: one: "Maximum %{count} user can be added at once" other: "Maximum %{count} users can be added at once" usernames_or_emails_required: "Usernames or emails must be present" - no_invites_with_sso: "You can invite only registered users when SSO is enabled" + no_invites_with_discourse_connect: "You can invite only registered users when DiscourseConnect is enabled" no_invites_without_local_logins: "You can invite only registered users when local logins are disabled" default_names: everyone: "everyone" @@ -1532,7 +1532,7 @@ en: detailed_404: "Provides more details to users about why they can’t access a particular topic. Note: This is less secure because users will know if a URL links to a valid topic." enforce_second_factor: "Forces users to enable two-factor authentication. Select 'all' to enforce it to all users. Select 'staff' to enforce it to staff users only." force_https: "Force your site to use HTTPS only. WARNING: do NOT enable this until you verify HTTPS is fully set up and working absolutely everywhere! Did you check your CDN, all social logins, and any external logos / dependencies to make sure they are all HTTPS compatible, too?" - same_site_cookies: "Use same site cookies, they eliminate all vectors Cross Site Request Forgery on supported browsers (Lax or Strict). Warning: Strict will only work on sites that force login and use SSO." + same_site_cookies: "Use same site cookies, they eliminate all vectors Cross Site Request Forgery on supported browsers (Lax or Strict). Warning: Strict will only work on sites that force login and use an external auth method." summary_score_threshold: "The minimum score required for a post to be included in 'Summarize This Topic'" summary_posts_required: "Minimum posts in a topic before 'Summarize This Topic' is enabled. Changes to this setting will be applied retroactively within a week." summary_likes_required: "Minimum likes in a topic before 'Summarize This Topic' is enabled. Changes to this setting will be applied retroactively within a week." @@ -1656,27 +1656,27 @@ en: password_unique_characters: "Minimum number of unique characters that a password must have." block_common_passwords: "Don't allow passwords that are in the 10,000 most common passwords." - external_auth_skip_create_confirm: When signing up via external auth, skip the create account popup. Best used alongside sso_overrides_email, sso_overrides_username and sso_overrides_name. - external_auth_immediately: "Automatically redirect to the external login system without user interaction. This only takes effect when login_required is true, and there is only one external authentication method" + auth_skip_create_confirm: When signing up via external auth, skip the create account popup. Best used alongside auth_overrides_email, auth_overrides_username and auth_overrides_name. + auth_immediately: "Automatically redirect to the external login system without user interaction. This only takes effect when login_required is true, and there is only one external authentication method" - enable_sso: "Enable single sign on via an external site (WARNING: USERS' EMAIL ADDRESSES *MUST* BE VALIDATED BY THE EXTERNAL SITE!)" - verbose_sso_logging: "Log verbose SSO related diagnostics to /logs" - enable_sso_provider: "Implement Discourse SSO provider protocol at the /session/sso_provider endpoint, requires sso_provider_secrets to be set" - sso_url: "URL of single sign on endpoint (must include http:// or https://)" - sso_secret: "Secret string used to cryptographically authenticate SSO information, be sure it is 10 characters or longer" - sso_provider_secrets: "A list of domain-secret pairs that are using Discourse as an SSO provider. Make sure SSO secret is 10 characters or longer. Wildcard symbol * can be used to match any domain or only a part of it (e.g. *.example.com)." - sso_overrides_bio: "Overrides user bio in user profile and prevents user from changing it" - sso_overrides_groups: "Synchronize all manual group membership with groups specified in the groups sso attribute (WARNING: if you do not specify groups all manual group membership will be cleared for user)" - sso_overrides_email: "Overrides local email with external site email from SSO payload on every login, and prevent local changes. Applies to all authentication providers. (WARNING: discrepancies can occur due to normalization of local emails)" - sso_overrides_username: "Overrides local username with external site username from SSO payload on every login, and prevent local changes. Applies to all authentication providers. (WARNING: discrepancies can occur due to differences in username length/requirements)" - sso_overrides_name: "Overrides local full name with external site full name from SSO payload on every login, and prevent local changes. Applies to all authentication providers." - sso_overrides_avatar: "Overrides user avatar with external site avatar from SSO payload. If enabled, users will not be allowed to upload avatars on Discourse." - sso_overrides_location: "Overrides user location with external location from SSO payload and prevent local changes." - sso_overrides_website: "Overrides user website with external location from SSO payload and prevent local changes." - sso_overrides_profile_background: "Overrides user profile background with external site avatar from SSO payload." - sso_overrides_card_background: "Overrides user card background with external site avatar from SSO payload." - sso_not_approved_url: "Redirect unapproved SSO accounts to this URL" - sso_allows_all_return_paths: "Do not restrict the domain for return_paths provided by SSO (by default return path must be on current site)" + enable_discourse_connect: "Enable sign on via DiscourseConnect (formerly 'Discourse SSO') (WARNING: USERS' EMAIL ADDRESSES *MUST* BE VALIDATED BY THE EXTERNAL SITE!)" + verbose_discourse_connect_logging: "Log verbose DiscourseConnect related diagnostics to /logs" + enable_discourse_connect_provider: "Implement DiscourseConnect (formerly 'Discourse SSO') provider protocol at the /session/sso_provider endpoint, requires discourse_connect_provider_secrets to be set" + discourse_connect_url: "URL of DiscourseConnect endpoint (must include http:// or https://)" + discourse_connect_secret: "Secret string used to cryptographically authenticate DiscourseConnect information, be sure it is 10 characters or longer" + discourse_connect_provider_secrets: "A list of domain-secret pairs that are using DiscourseConnect. Make sure DiscourseConnect secret is 10 characters or longer. Wildcard symbol * can be used to match any domain or only a part of it (e.g. *.example.com)." + discourse_connect_overrides_bio: "Overrides user bio in user profile and prevents user from changing it" + discourse_connect_overrides_groups: "Synchronize all manual group membership with groups specified in the groups attribute (WARNING: if you do not specify groups all manual group membership will be cleared for user)" + auth_overrides_email: "Overrides local email with external site email on every login, and prevent local changes. Applies to all authentication providers. (WARNING: discrepancies can occur due to normalization of local emails)" + auth_overrides_username: "Overrides local username with external site username on every login, and prevent local changes. Applies to all authentication providers. (WARNING: discrepancies can occur due to differences in username length/requirements)" + auth_overrides_name: "Overrides local full name with external site full name on every login, and prevent local changes. Applies to all authentication providers." + discourse_connect_overrides_avatar: "Overrides user avatar with external site avatar from DiscourseConnect payload. If enabled, users will not be allowed to upload avatars on Discourse." + discourse_connect_overrides_location: "Overrides user location with external location from DiscourseConnect payload and prevent local changes." + discourse_connect_overrides_website: "Overrides user website with external location from DiscourseConnect payload and prevent local changes." + discourse_connect_overrides_profile_background: "Overrides user profile background with external site avatar from DiscourseConnect payload." + discourse_connect_overrides_card_background: "Overrides user card background with external site avatar from DiscourseConnect payload." + discourse_connect_not_approved_url: "Redirect unapproved DiscourseConnect accounts to this URL" + discourse_connect_allows_all_return_paths: "Do not restrict the domain for return_paths provided by DiscourseConnect (by default return path must be on current site)" enable_local_logins: "Enable local username and password login based accounts. This must be enabled for invites to work. WARNING: if disabled, you may be unable to log in if you have not previously configured at least one alternate login method." enable_local_logins_via_email: "Allow users to request a one-click login link to be sent to them via email." @@ -2313,8 +2313,8 @@ en: email_editable_enabled: "You must disable 'email editable' before enabling this setting." staged_users_disabled: "You must first enable 'staged users' before enabling this setting." reply_by_email_disabled: "You must first enable 'reply by email' before enabling this setting." - sso_url_is_empty: "You must set a 'sso url' before enabling this setting." - sso_invite_only: "You cannot enable sso and invite only at the same time." + discourse_connect_url_is_empty: "You must set a 'discourse connect url' before enabling this setting." + discourse_connect_invite_only: "You cannot enable DiscourseConnect and invite only at the same time." enable_local_logins_disabled: "You must first enable 'enable local logins' before enabling this setting." min_username_length_exists: "You cannot set the minimum username length above the shortest username (%{username})." min_username_length_range: "You cannot set the minimum above the maximum." @@ -2334,9 +2334,9 @@ en: list_value_count: "The list must contain exactly %{count} values." placeholder: - sso_provider_secrets: + discourse_connect_provider_secrets: key: "www.example.com" - value: "SSO secret" + value: "DiscourseConnect secret" search: extreme_load_error: "Site is under extreme load, search is disabled, try again later" @@ -2349,7 +2349,7 @@ en: audio: "[audio]" video: "[video]" - sso: + discourse_connect: login_error: "Login Error" not_found: "Your account couldn't be found. Please contact the site's administrator." account_not_approved: "Your account is pending approval. You will receive an email notification when you are approved." @@ -2358,7 +2358,7 @@ en: no_email: "No email address was provided. Please contact the site's administrator." blank_id_error: "The `external_id` is required but was blank" email_error: "An account could not be registered with the email address %{email}. Please contact the site's administrator." - missing_secret: "SSO authentication failed due to missing secret. Contact the site administrators to fix this problem." + missing_secret: "Authentication failed due to missing secret. Contact the site administrators to fix this problem." original_poster: "Original Poster" most_posts: "Most Posts" diff --git a/config/site_settings.yml b/config/site_settings.yml index aa4c21dd6a9..415094f9bf6 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -423,31 +423,31 @@ login: default: "" type: list list_type: simple - external_auth_skip_create_confirm: + auth_skip_create_confirm: default: false client: true - external_auth_immediately: + auth_immediately: default: true - enable_sso: + enable_discourse_connect: client: true default: false validator: "EnableSsoValidator" - sso_allows_all_return_paths: false - enable_sso_provider: false - verbose_sso_logging: false + discourse_connect_allows_all_return_paths: false + enable_discourse_connect_provider: false + verbose_discourse_connect_logging: false verbose_auth_token_logging: hidden: true default: true max_suspicious_distance_km: hidden: true default: 500 - sso_url: + discourse_connect_url: default: "" regex: '^https?:\/\/.+[^\/]$' - sso_secret: + discourse_connect_secret: default: "" secret: true - sso_provider_secrets: + discourse_connect_provider_secrets: default: "" type: list list_type: secret @@ -455,22 +455,22 @@ login: placeholder: key: "sso_provider.key_placeholder" value: "sso_provider.value_placeholder" - sso_overrides_groups: false - sso_overrides_bio: false - sso_overrides_email: + discourse_connect_overrides_groups: false + discourse_connect_overrides_bio: false + auth_overrides_email: default: false validator: "SsoOverridesEmailValidator" client: true - sso_overrides_username: false - sso_overrides_name: false - sso_overrides_avatar: + auth_overrides_username: false + auth_overrides_name: false + discourse_connect_overrides_avatar: default: false client: true - sso_overrides_profile_background: false - sso_overrides_location: false - sso_overrides_website: false - sso_overrides_card_background: false - sso_not_approved_url: "" + discourse_connect_overrides_profile_background: false + discourse_connect_overrides_location: false + discourse_connect_overrides_website: false + discourse_connect_overrides_card_background: false + discourse_connect_not_approved_url: "" blocked_email_domains: default: "mailinator.com" type: list diff --git a/db/migrate/20181005084357_add_sso_provider_secrets_to_site_settings.rb b/db/migrate/20181005084357_add_sso_provider_secrets_to_site_settings.rb index 777e665a6d2..877dc72f1f3 100644 --- a/db/migrate/20181005084357_add_sso_provider_secrets_to_site_settings.rb +++ b/db/migrate/20181005084357_add_sso_provider_secrets_to_site_settings.rb @@ -2,12 +2,14 @@ class AddSsoProviderSecretsToSiteSettings < ActiveRecord::Migration[5.2] def up - return unless SiteSetting.enable_sso_provider && SiteSetting.sso_secret.present? - sso_secret = SiteSetting.sso_secret - sso_secret_insert = ActiveRecord::Base.connection.quote("*|#{sso_secret}") - - execute "INSERT INTO site_settings(name, data_type, value, created_at, updated_at) - VALUES ('sso_provider_secrets', 8, #{sso_secret_insert}, now(), now())" + execute <<~SQL + INSERT INTO site_settings(name, data_type, value, created_at, updated_at) + SELECT 'sso_provider_secrets', 8, '*|' || value, now(), now() + FROM site_settings WHERE name = 'sso_secret' + AND EXISTS ( + SELECT 1 FROM site_settings WHERE name = 'enable_sso_provider' AND value = 't' + ) + SQL end def down diff --git a/db/migrate/20210204135429_rename_sso_site_settings.rb b/db/migrate/20210204135429_rename_sso_site_settings.rb new file mode 100644 index 00000000000..8fb149b1ee1 --- /dev/null +++ b/db/migrate/20210204135429_rename_sso_site_settings.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +class RenameSsoSiteSettings < ActiveRecord::Migration[6.0] + RENAME_SETTINGS = [ + ['enable_sso', 'enable_discourse_connect'], + ['sso_allows_all_return_paths', 'discourse_connect_allows_all_return_paths'], + ['enable_sso_provider', 'enable_discourse_connect_provider'], + ['verbose_sso_logging', 'verbose_discourse_connect_logging'], + ['sso_url', 'discourse_connect_url'], + ['sso_secret', 'discourse_connect_secret'], + ['sso_provider_secrets', 'discourse_connect_provider_secrets'], + ['sso_overrides_groups', 'discourse_connect_overrides_groups'], + ['sso_overrides_bio', 'discourse_connect_overrides_bio'], + ['sso_overrides_email', 'auth_overrides_email'], + ['sso_overrides_username', 'auth_overrides_username'], + ['sso_overrides_name', 'auth_overrides_name'], + ['sso_overrides_avatar', 'discourse_connect_overrides_avatar'], + ['sso_overrides_profile_background', 'discourse_connect_overrides_profile_background'], + ['sso_overrides_location', 'discourse_connect_overrides_location'], + ['sso_overrides_website', 'discourse_connect_overrides_website'], + ['sso_overrides_card_background', 'discourse_connect_overrides_card_background'], + ['external_auth_skip_create_confirm', 'auth_skip_create_confirm'], + ['external_auth_immediately', 'auth_immediately'] + ] + + def up + # Copying the rows so that things keep working during deploy + # TODO: Add a post-deploy migration to drop the old rows + + RENAME_SETTINGS.each do |old_name, new_name| + execute <<~SQL + INSERT INTO site_settings (name, data_type, value, created_at, updated_at) + SELECT '#{new_name}', data_type, value, created_at, updated_at + FROM site_settings + WHERE name = '#{old_name}' + SQL + end + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end diff --git a/lib/auth/result.rb b/lib/auth/result.rb index 18dff598aa6..5cad43107b0 100644 --- a/lib/auth/result.rb +++ b/lib/auth/result.rb @@ -70,17 +70,17 @@ class Auth::Result def apply_user_attributes! change_made = false - if SiteSetting.sso_overrides_username? && username.present? && username != user.username + if SiteSetting.auth_overrides_username? && username.present? && username != user.username user.username = UserNameSuggester.suggest(username || name || email, user.username) change_made = true end - if SiteSetting.sso_overrides_email && email_valid && email.present? && user.email != Email.downcase(email) + if SiteSetting.auth_overrides_email && email_valid && email.present? && user.email != Email.downcase(email) user.email = email change_made = true end - if SiteSetting.sso_overrides_name && name.present? && user.name != name + if SiteSetting.auth_overrides_name && name.present? && user.name != name user.name = name change_made = true end @@ -89,11 +89,11 @@ class Auth::Result end def can_edit_name - !SiteSetting.sso_overrides_name + !SiteSetting.auth_overrides_name end def can_edit_username - !(SiteSetting.sso_overrides_username || omit_username) + !(SiteSetting.auth_overrides_username || omit_username) end def to_client_hash diff --git a/lib/composer_messages_finder.rb b/lib/composer_messages_finder.rb index f1f9aa33d82..251091d0e04 100644 --- a/lib/composer_messages_finder.rb +++ b/lib/composer_messages_finder.rb @@ -78,7 +78,7 @@ class ComposerMessagesFinder # - "disable avatar education message" is enabled # - "sso overrides avatar" is enabled # - "allow uploaded avatars" is disabled - return if SiteSetting.disable_avatar_education_message || SiteSetting.sso_overrides_avatar || !SiteSetting.allow_uploaded_avatars + return if SiteSetting.disable_avatar_education_message || SiteSetting.discourse_connect_overrides_avatar || !SiteSetting.allow_uploaded_avatars # If we got this far, log that we've nagged them about the avatar UserHistory.create!(action: UserHistory.actions[:notified_about_avatar], target_user_id: @user.id) diff --git a/lib/guardian.rb b/lib/guardian.rb index b82966296f2..147329c352e 100644 --- a/lib/guardian.rb +++ b/lib/guardian.rb @@ -353,7 +353,7 @@ class Guardian def can_invite_to_forum?(groups = nil) authenticated? && (SiteSetting.max_invites_per_day.to_i > 0 || is_staff?) && - !SiteSetting.enable_sso && + !SiteSetting.enable_discourse_connect && SiteSetting.enable_local_logins && ( (!SiteSetting.must_approve_users? && @user.has_trust_level?(SiteSetting.min_trust_level_to_allow_invite.to_i)) || @@ -391,7 +391,7 @@ class Guardian def can_invite_via_email?(object) return false unless can_invite_to?(object) - !SiteSetting.enable_sso && SiteSetting.enable_local_logins && (!SiteSetting.must_approve_users? || is_staff?) + !SiteSetting.enable_discourse_connect && SiteSetting.enable_local_logins && (!SiteSetting.must_approve_users? || is_staff?) end def can_bulk_invite_to_forum?(user) diff --git a/lib/guardian/user_guardian.rb b/lib/guardian/user_guardian.rb index c26ec89aa8e..099267b7eb3 100644 --- a/lib/guardian/user_guardian.rb +++ b/lib/guardian/user_guardian.rb @@ -23,7 +23,7 @@ module UserGuardian end def can_edit_username?(user) - return false if SiteSetting.sso_overrides_username? + return false if SiteSetting.auth_overrides_username? return true if is_staff? return false if SiteSetting.username_change_period <= 0 return false if is_anonymous? @@ -31,7 +31,7 @@ module UserGuardian end def can_edit_email?(user) - return false if SiteSetting.sso_overrides_email? + return false if SiteSetting.auth_overrides_email? return false unless SiteSetting.email_editable? return true if is_staff? return false if is_anonymous? @@ -40,7 +40,7 @@ module UserGuardian def can_edit_name?(user) return false unless SiteSetting.enable_names? - return false if SiteSetting.sso_overrides_name? + return false if SiteSetting.auth_overrides_name? return true if is_staff? return false if is_anonymous? can_edit?(user) @@ -61,7 +61,7 @@ module UserGuardian def can_delete_user?(user) return false if user.nil? || user.admin? if is_me?(user) - !SiteSetting.enable_sso && + !SiteSetting.enable_discourse_connect && !user.has_more_posts_than?(SiteSetting.delete_user_self_max_post_count) else is_staff? && ( @@ -173,6 +173,6 @@ module UserGuardian end def can_delete_sso_record?(user) - SiteSetting.enable_sso && user && is_admin? + SiteSetting.enable_discourse_connect && user && is_admin? end end diff --git a/lib/single_sign_on_provider.rb b/lib/single_sign_on_provider.rb index a626ffcf269..3e744430ba2 100644 --- a/lib/single_sign_on_provider.rb +++ b/lib/single_sign_on_provider.rb @@ -7,7 +7,7 @@ class SingleSignOnProvider < SingleSignOn set_return_sso_url(payload) if sso_secret.blank? && self.sso_secret.blank? host = URI.parse(@return_sso_url).host - Rails.logger.warn("SSO failed; website #{host} is not in the `sso_provider_secrets` site settings") + Rails.logger.warn("SSO failed; website #{host} is not in the `discourse_connect_provider_secrets` site settings") raise BlankSecret end @@ -24,9 +24,9 @@ class SingleSignOnProvider < SingleSignOn end def self.sso_secret - return nil unless @return_sso_url && SiteSetting.enable_sso_provider + return nil unless @return_sso_url && SiteSetting.enable_discourse_connect_provider - provider_secrets = SiteSetting.sso_provider_secrets.split(/[|\n]/) + provider_secrets = SiteSetting.discourse_connect_provider_secrets.split(/[|\n]/) provider_secrets_hash = Hash[*provider_secrets] return_url_host = URI.parse(@return_sso_url).host # moves wildcard domains to the end of hash diff --git a/lib/site_settings/deprecated_settings.rb b/lib/site_settings/deprecated_settings.rb index 60e6a909eda..85ed2f4caeb 100644 --- a/lib/site_settings/deprecated_settings.rb +++ b/lib/site_settings/deprecated_settings.rb @@ -10,7 +10,27 @@ module SiteSettings::DeprecatedSettings ['enable_category_group_review', 'enable_category_group_moderation', true, '2.7'], ['newuser_max_images', 'newuser_max_embedded_media', true, '2.7'], ['min_trust_to_post_images', 'min_trust_to_post_embedded_media', true, '2.7'], - ['moderators_create_categories', 'moderators_manage_categories_and_groups', '2.7'] + ['moderators_create_categories', 'moderators_manage_categories_and_groups', '2.7'], + + ['enable_sso', 'enable_discourse_connect', true, '2.8'], + ['sso_allows_all_return_paths', 'discourse_connect_allows_all_return_paths', true, '2.8'], + ['enable_sso_provider', 'enable_discourse_connect_provider', true, '2.8'], + ['verbose_sso_logging', 'verbose_discourse_connect_logging', true, '2.8'], + ['sso_url', 'discourse_connect_url', true, '2.8'], + ['sso_secret', 'discourse_connect_secret', true, '2.8'], + ['sso_provider_secrets', 'discourse_connect_provider_secrets', true, '2.8'], + ['sso_overrides_groups', 'discourse_connect_overrides_groups', true, '2.8'], + ['sso_overrides_bio', 'discourse_connect_overrides_bio', true, '2.8'], + ['sso_overrides_email', 'auth_overrides_email', true, '2.8'], + ['sso_overrides_username', 'auth_overrides_username', true, '2.8'], + ['sso_overrides_name', 'auth_overrides_name', true, '2.8'], + ['sso_overrides_avatar', 'discourse_connect_overrides_avatar', true, '2.8'], + ['sso_overrides_profile_background', 'discourse_connect_overrides_profile_background', true, '2.8'], + ['sso_overrides_location', 'discourse_connect_overrides_location', true, '2.8'], + ['sso_overrides_website', 'discourse_connect_overrides_website', true, '2.8'], + ['sso_overrides_card_background', 'discourse_connect_overrides_card_background', true, '2.8'], + ['external_auth_skip_create_confirm', 'auth_skip_create_confirm', true, '2.8'], + ['external_auth_immediately', 'auth_immediately', true, '2.8'], ] def setup_deprecated_methods diff --git a/lib/site_settings/validations.rb b/lib/site_settings/validations.rb index 81090bfe1c1..ebfcbfcfe14 100644 --- a/lib/site_settings/validations.rb +++ b/lib/site_settings/validations.rb @@ -177,8 +177,8 @@ module SiteSettings::Validations end def validate_enforce_second_factor(new_val) - if SiteSetting.enable_sso? - return validate_error :second_factor_cannot_be_enforced_with_sso_enabled + if SiteSetting.enable_discourse_connect? + return validate_error :second_factor_cannot_be_enforced_with_discourse_connect_enabled end if new_val == "all" && Discourse.enabled_auth_providers.count > 0 auth_provider_names = Discourse.enabled_auth_providers.map(&:name).join(", ") diff --git a/lib/validators/enable_invite_only_validator.rb b/lib/validators/enable_invite_only_validator.rb index 63fd259bc08..b2efcdf83f5 100644 --- a/lib/validators/enable_invite_only_validator.rb +++ b/lib/validators/enable_invite_only_validator.rb @@ -7,10 +7,10 @@ class EnableInviteOnlyValidator def valid_value?(val) return true if val == 'f' - !SiteSetting.enable_sso? + !SiteSetting.enable_discourse_connect? end def error_message - I18n.t('site_settings.errors.sso_invite_only') + I18n.t('site_settings.errors.discourse_connect_invite_only') end end diff --git a/lib/validators/enable_sso_validator.rb b/lib/validators/enable_sso_validator.rb index e119cc29ba6..6c71904d768 100644 --- a/lib/validators/enable_sso_validator.rb +++ b/lib/validators/enable_sso_validator.rb @@ -7,12 +7,12 @@ class EnableSsoValidator def valid_value?(val) return true if val == 'f' - return false if SiteSetting.sso_url.blank? || SiteSetting.invite_only? + return false if SiteSetting.discourse_connect_url.blank? || SiteSetting.invite_only? true end def error_message - return I18n.t('site_settings.errors.sso_url_is_empty') if SiteSetting.sso_url.blank? - return I18n.t('site_settings.errors.sso_invite_only') if SiteSetting.invite_only? + return I18n.t('site_settings.errors.discourse_connect_url_is_empty') if SiteSetting.discourse_connect_url.blank? + return I18n.t('site_settings.errors.discourse_connect_invite_only') if SiteSetting.invite_only? end end diff --git a/script/benchmarks/site_setting/bench.rb b/script/benchmarks/site_setting/bench.rb index 902911d44fb..5790b41ffa8 100644 --- a/script/benchmarks/site_setting/bench.rb +++ b/script/benchmarks/site_setting/bench.rb @@ -14,7 +14,7 @@ SiteSetting.refresh! tests = [ ["current cache", lambda do SiteSetting.title - SiteSetting.enable_sso + SiteSetting.enable_discourse_connect end ], ["change default locale with current cache refreshed", lambda do diff --git a/script/benchmarks/site_setting/profile.rb b/script/benchmarks/site_setting/profile.rb index 0ad7bcde079..a849a18a363 100644 --- a/script/benchmarks/site_setting/profile.rb +++ b/script/benchmarks/site_setting/profile.rb @@ -13,7 +13,7 @@ require File.expand_path('../../../../config/environment', __FILE__) # warming up SiteSetting.title -SiteSetting.enable_sso +SiteSetting.enable_discourse_connect SiteSetting.default_locale = SiteSetting.default_locale == 'en' ? 'zh_CN' : 'en' SiteSetting.title = SecureRandom.hex @@ -22,7 +22,7 @@ profile do end profile do - SiteSetting.enable_sso + SiteSetting.enable_discourse_connect end profile do diff --git a/spec/components/composer_messages_finder_spec.rb b/spec/components/composer_messages_finder_spec.rb index 00cb9ac9952..50a8325576b 100644 --- a/spec/components/composer_messages_finder_spec.rb +++ b/spec/components/composer_messages_finder_spec.rb @@ -138,8 +138,8 @@ describe ComposerMessagesFinder do expect(finder.check_avatar_notification).to be_blank end - it "doesn't notify users if 'sso_overrides_avatar' setting is enabled" do - SiteSetting.sso_overrides_avatar = true + it "doesn't notify users if 'discourse_connect_overrides_avatar' setting is enabled" do + SiteSetting.discourse_connect_overrides_avatar = true expect(finder.check_avatar_notification).to be_blank end diff --git a/spec/components/concern/second_factor_manager_spec.rb b/spec/components/concern/second_factor_manager_spec.rb index 0be7d5b9d41..865b1113bb4 100644 --- a/spec/components/concern/second_factor_manager_spec.rb +++ b/spec/components/concern/second_factor_manager_spec.rb @@ -111,8 +111,8 @@ RSpec.describe SecondFactorManager do describe 'when SSO is enabled' do it 'should return false' do - SiteSetting.sso_url = 'http://someurl.com' - SiteSetting.enable_sso = true + SiteSetting.discourse_connect_url = 'http://someurl.com' + SiteSetting.enable_discourse_connect = true expect(user.totp_enabled?).to eq(false) end @@ -437,8 +437,8 @@ RSpec.describe SecondFactorManager do describe 'when SSO is enabled' do it 'should return false' do - SiteSetting.sso_url = 'http://someurl.com' - SiteSetting.enable_sso = true + SiteSetting.discourse_connect_url = 'http://someurl.com' + SiteSetting.enable_discourse_connect = true expect(user_backup.backup_codes_enabled?).to eq(false) end diff --git a/spec/components/guardian/user_guardian_spec.rb b/spec/components/guardian/user_guardian_spec.rb index 9d289d32160..9cd1af1a555 100644 --- a/spec/components/guardian/user_guardian_spec.rb +++ b/spec/components/guardian/user_guardian_spec.rb @@ -237,8 +237,8 @@ describe UserGuardian do include_examples "can_delete_user examples" it "isn't allowed when SSO is enabled" do - SiteSetting.sso_url = "https://www.example.com/sso" - SiteSetting.enable_sso = true + SiteSetting.discourse_connect_url = "https://www.example.com/sso" + SiteSetting.enable_discourse_connect = true expect(guardian.can_delete_user?(user)).to eq(false) end diff --git a/spec/components/guardian_spec.rb b/spec/components/guardian_spec.rb index 68b39f89fc9..c292582360c 100644 --- a/spec/components/guardian_spec.rb +++ b/spec/components/guardian_spec.rb @@ -690,8 +690,8 @@ describe Guardian do end it 'returns false for all users when sso is enabled' do - SiteSetting.sso_url = "https://www.example.com/sso" - SiteSetting.enable_sso = true + SiteSetting.discourse_connect_url = "https://www.example.com/sso" + SiteSetting.enable_discourse_connect = true expect(Guardian.new(trust_level_2).can_invite_via_email?(topic)).to be_falsey expect(Guardian.new(moderator).can_invite_via_email?(topic)).to be_falsey @@ -2714,9 +2714,9 @@ describe Guardian do context 'when SSO username override is active' do before do - SiteSetting.sso_url = "https://www.example.com/sso" - SiteSetting.enable_sso = true - SiteSetting.sso_overrides_username = true + SiteSetting.discourse_connect_url = "https://www.example.com/sso" + SiteSetting.enable_discourse_connect = true + SiteSetting.auth_overrides_username = true end it "is false for admins" do @@ -2799,9 +2799,9 @@ describe Guardian do context 'when SSO email override is active' do before do SiteSetting.email_editable = false - SiteSetting.sso_url = "https://www.example.com/sso" - SiteSetting.enable_sso = true - SiteSetting.sso_overrides_email = true + SiteSetting.discourse_connect_url = "https://www.example.com/sso" + SiteSetting.enable_discourse_connect = true + SiteSetting.auth_overrides_email = true end it "is false for admins" do @@ -2878,8 +2878,8 @@ describe Guardian do context 'when SSO is disabled' do before do - SiteSetting.enable_sso = false - SiteSetting.sso_overrides_name = false + SiteSetting.enable_discourse_connect = false + SiteSetting.auth_overrides_name = false end it 'is true for admins' do @@ -2897,13 +2897,13 @@ describe Guardian do context 'when SSO is enabled' do before do - SiteSetting.sso_url = "https://www.example.com/sso" - SiteSetting.enable_sso = true + SiteSetting.discourse_connect_url = "https://www.example.com/sso" + SiteSetting.enable_discourse_connect = true end context 'when SSO name override is active' do before do - SiteSetting.sso_overrides_name = true + SiteSetting.auth_overrides_name = true end it 'is false for admins' do @@ -2921,7 +2921,7 @@ describe Guardian do context 'when SSO name override is not active' do before do - SiteSetting.sso_overrides_name = false + SiteSetting.auth_overrides_name = false end it 'is true for admins' do diff --git a/spec/components/validators/enable_invite_only_validator_spec.rb b/spec/components/validators/enable_invite_only_validator_spec.rb index fe3af0dccb6..fab1d200686 100644 --- a/spec/components/validators/enable_invite_only_validator_spec.rb +++ b/spec/components/validators/enable_invite_only_validator_spec.rb @@ -7,8 +7,8 @@ RSpec.describe EnableInviteOnlyValidator do context "when sso is enabled" do before do - SiteSetting.sso_url = "https://example.com/sso" - SiteSetting.enable_sso = true + SiteSetting.discourse_connect_url = "https://example.com/sso" + SiteSetting.enable_discourse_connect = true end it "is valid when false" do @@ -18,7 +18,7 @@ RSpec.describe EnableInviteOnlyValidator do it "is isn't value for true" do expect(subject.valid_value?('t')).to eq(false) expect(subject.error_message).to eq(I18n.t( - 'site_settings.errors.sso_invite_only' + 'site_settings.errors.discourse_connect_invite_only' )) end end diff --git a/spec/components/validators/enable_sso_validator_spec.rb b/spec/components/validators/enable_sso_validator_spec.rb index 9114792d27f..3a2e549b92b 100644 --- a/spec/components/validators/enable_sso_validator_spec.rb +++ b/spec/components/validators/enable_sso_validator_spec.rb @@ -8,7 +8,7 @@ RSpec.describe EnableSsoValidator do describe '#valid_value?' do describe "when 'sso url' is empty" do before do - SiteSetting.sso_url = "" + SiteSetting.discourse_connect_url = "" end describe 'when val is false' do @@ -22,7 +22,7 @@ RSpec.describe EnableSsoValidator do expect(subject.valid_value?('t')).to eq(false) expect(subject.error_message).to eq(I18n.t( - 'site_settings.errors.sso_url_is_empty' + 'site_settings.errors.discourse_connect_url_is_empty' )) end end @@ -31,7 +31,7 @@ RSpec.describe EnableSsoValidator do describe "when invite_only is set" do before do SiteSetting.invite_only = true - SiteSetting.sso_url = 'https://example.com/sso' + SiteSetting.discourse_connect_url = 'https://example.com/sso' end it 'allows a false value' do @@ -41,14 +41,14 @@ RSpec.describe EnableSsoValidator do it "doesn't allow true" do expect(subject.valid_value?('t')).to eq(false) expect(subject.error_message).to eq(I18n.t( - 'site_settings.errors.sso_invite_only' + 'site_settings.errors.discourse_connect_invite_only' )) end end describe "when 'sso url' is present" do before do - SiteSetting.sso_url = "https://www.example.com/sso" + SiteSetting.discourse_connect_url = "https://www.example.com/sso" end describe 'when value is false' do diff --git a/spec/components/validators/sso_overrides_email_validator_spec.rb b/spec/components/validators/sso_overrides_email_validator_spec.rb index c4b0da34e16..a7951c632b0 100644 --- a/spec/components/validators/sso_overrides_email_validator_spec.rb +++ b/spec/components/validators/sso_overrides_email_validator_spec.rb @@ -8,8 +8,8 @@ RSpec.describe SsoOverridesEmailValidator do describe '#valid_value?' do describe "when 'email editable' is true" do before do - SiteSetting.sso_url = "https://www.example.com/sso" - SiteSetting.enable_sso = true + SiteSetting.discourse_connect_url = "https://www.example.com/sso" + SiteSetting.enable_discourse_connect = true SiteSetting.email_editable = true end @@ -32,8 +32,8 @@ RSpec.describe SsoOverridesEmailValidator do describe "when 'email editable' is false" do before do - SiteSetting.sso_url = "https://www.example.com/sso" - SiteSetting.enable_sso = true + SiteSetting.discourse_connect_url = "https://www.example.com/sso" + SiteSetting.enable_discourse_connect = true SiteSetting.email_editable = false end diff --git a/spec/jobs/export_csv_file_spec.rb b/spec/jobs/export_csv_file_spec.rb index 16c1023512b..f53d0536e50 100644 --- a/spec/jobs/export_csv_file_spec.rb +++ b/spec/jobs/export_csv_file_spec.rb @@ -210,8 +210,8 @@ describe Jobs::ExportCsvFile do end it 'exports sso data' do - SiteSetting.sso_url = "https://www.example.com/sso" - SiteSetting.enable_sso = true + SiteSetting.discourse_connect_url = "https://www.example.com/sso" + SiteSetting.enable_discourse_connect = true user = Fabricate(:user) user.user_profile.update_column(:location, "La,La Land") user.create_single_sign_on_record(external_id: "123", last_payload: "xxx", external_email: 'test@test.com') diff --git a/spec/lib/site_settings/validations_spec.rb b/spec/lib/site_settings/validations_spec.rb index 4f8358ff958..747099f39aa 100644 --- a/spec/lib/site_settings/validations_spec.rb +++ b/spec/lib/site_settings/validations_spec.rb @@ -151,10 +151,10 @@ describe SiteSettings::Validations do end context "when SSO is enabled" do - let(:error_message) { I18n.t("errors.site_settings.second_factor_cannot_be_enforced_with_sso_enabled") } + let(:error_message) { I18n.t("errors.site_settings.second_factor_cannot_be_enforced_with_discourse_connect_enabled") } before do - SiteSetting.sso_url = "https://www.example.com/sso" - SiteSetting.enable_sso = true + SiteSetting.discourse_connect_url = "https://www.example.com/sso" + SiteSetting.enable_discourse_connect = true end it "should raise an error" do diff --git a/spec/models/discourse_single_sign_on_spec.rb b/spec/models/discourse_single_sign_on_spec.rb index fb318d16bcc..7867cfd38e1 100644 --- a/spec/models/discourse_single_sign_on_spec.rb +++ b/spec/models/discourse_single_sign_on_spec.rb @@ -4,12 +4,12 @@ require "rails_helper" describe DiscourseSingleSignOn do before do - @sso_url = "http://example.com/discourse_sso" - @sso_secret = "shjkfdhsfkjh" + @discourse_connect_url = "http://example.com/discourse_sso" + @discourse_connect_secret = "shjkfdhsfkjh" - SiteSetting.sso_url = @sso_url - SiteSetting.enable_sso = true - SiteSetting.sso_secret = @sso_secret + SiteSetting.discourse_connect_url = @discourse_connect_url + SiteSetting.enable_discourse_connect = true + SiteSetting.discourse_connect_secret = @discourse_connect_secret Jobs.run_immediately! end @@ -114,7 +114,7 @@ describe DiscourseSingleSignOn do end it "unstaged users" do - SiteSetting.sso_overrides_name = true + SiteSetting.auth_overrides_name = true email = "staged@user.com" Fabricate(:user, staged: true, email: email) @@ -195,7 +195,7 @@ describe DiscourseSingleSignOn do sso.groups = "#{group2.name.capitalize},group4,badname,trust_level_4" sso.lookup_or_create_user(ip_address) - SiteSetting.sso_overrides_groups = true + SiteSetting.discourse_connect_overrides_groups = true group1.reload expect(group1.usernames).to eq("") @@ -260,7 +260,7 @@ describe DiscourseSingleSignOn do end it 'can override username properly when only the case changes' do - SiteSetting.sso_overrides_username = true + SiteSetting.auth_overrides_username = true sso = DiscourseSingleSignOn.new sso.username = "testuser" @@ -280,8 +280,8 @@ describe DiscourseSingleSignOn do expect(user.username).to eq "TestUser" end - it 'behaves properly when sso_overrides_username is set but username is missing or blank' do - SiteSetting.sso_overrides_username = true + it 'behaves properly when auth_overrides_username is set but username is missing or blank' do + SiteSetting.auth_overrides_username = true sso = DiscourseSingleSignOn.new sso.username = "testuser" @@ -310,9 +310,9 @@ describe DiscourseSingleSignOn do admin = Fabricate(:admin) SiteSetting.email_editable = false - SiteSetting.sso_overrides_name = true - SiteSetting.sso_overrides_email = true - SiteSetting.sso_overrides_username = true + SiteSetting.auth_overrides_name = true + SiteSetting.auth_overrides_email = true + SiteSetting.auth_overrides_username = true sso = DiscourseSingleSignOn.new sso.username = "bob%the$admin" @@ -378,7 +378,7 @@ describe DiscourseSingleSignOn do it "generates a correct sso url" do url, payload = DiscourseSingleSignOn.generate_url.split("?") - expect(url).to eq @sso_url + expect(url).to eq @discourse_connect_url sso = DiscourseSingleSignOn.parse(payload) expect(sso.nonce).to_not be_nil @@ -447,7 +447,7 @@ describe DiscourseSingleSignOn do it 'does not deactivate user if email provided is capitalized' do SiteSetting.email_editable = false - SiteSetting.sso_overrides_email = true + SiteSetting.auth_overrides_email = true sso.require_activation = true user = sso.lookup_or_create_user(ip_address) @@ -465,7 +465,7 @@ describe DiscourseSingleSignOn do it 'deactivates accounts that have updated email address' do SiteSetting.email_editable = false - SiteSetting.sso_overrides_email = true + SiteSetting.auth_overrides_email = true sso.require_activation = true user = sso.lookup_or_create_user(ip_address) @@ -567,7 +567,7 @@ describe DiscourseSingleSignOn do # yes override if site setting sso.bio = "new profile 2" - SiteSetting.sso_overrides_bio = true + SiteSetting.discourse_connect_overrides_bio = true user = sso.lookup_or_create_user(ip_address) expect(user.user_profile.bio_cooked).to match_html("new profile 2
"true", - "sso_url" => sso_url + "enable_discourse_connect" => "true", + "discourse_connect_url" => sso_url ) end end diff --git a/spec/services/user_updater_spec.rb b/spec/services/user_updater_spec.rb index 7ed290999e5..717bc0aa5d5 100644 --- a/spec/services/user_updater_spec.rb +++ b/spec/services/user_updater_spec.rb @@ -267,9 +267,9 @@ describe UserUpdater do context 'when sso overrides bio' do it 'does not change bio' do - SiteSetting.sso_url = "https://www.example.com/sso" - SiteSetting.enable_sso = true - SiteSetting.sso_overrides_bio = true + SiteSetting.discourse_connect_url = "https://www.example.com/sso" + SiteSetting.enable_discourse_connect = true + SiteSetting.discourse_connect_overrides_bio = true user = Fabricate(:user) updater = UserUpdater.new(acting_user, user) @@ -283,9 +283,9 @@ describe UserUpdater do context 'when sso overrides location' do it 'does not change location' do - SiteSetting.sso_url = "https://www.example.com/sso" - SiteSetting.enable_sso = true - SiteSetting.sso_overrides_location = true + SiteSetting.discourse_connect_url = "https://www.example.com/sso" + SiteSetting.enable_discourse_connect = true + SiteSetting.discourse_connect_overrides_location = true user = Fabricate(:user) updater = UserUpdater.new(acting_user, user) @@ -299,9 +299,9 @@ describe UserUpdater do context 'when sso overrides website' do it 'does not change website' do - SiteSetting.sso_url = "https://www.example.com/sso" - SiteSetting.enable_sso = true - SiteSetting.sso_overrides_website = true + SiteSetting.discourse_connect_url = "https://www.example.com/sso" + SiteSetting.enable_discourse_connect = true + SiteSetting.discourse_connect_overrides_website = true user = Fabricate(:user) updater = UserUpdater.new(acting_user, user)