* Split Settings::Authentication from SiteConfig * Move specs * Sort fields * Update settings usages * Update recaptcha usages * Add data update script * Update spec * Rename SiteConfigParams concern * Fixes, new route, new controller * Controller and service refactoring * More controller and service updates * Spec updates * More spec fixes * Move file * Fix FeedbackMessagesController * Update admin/configs_spec * Fix remaining specs in admin/configs_spec * Fix configs API * Formatting * Clean up old service object * Various fixes * Update DUS * Add model argument to admin_config_label * Fix key name * Fix specs * Add distinct request caches for settings classes * Fix e2e tests * Fix remaining system spec * Make DUS idempotent * Move routes block * Cleanup * Switch to ActiveSupport::CurrentAttributes * Pinned rails-settings-cached * Update e2e test * Update lib/data_update_scripts/20210316091354_move_authentication_settings.rb Co-authored-by: rhymes <rhymes@hey.com> * Add guard to DUS * Temporarily re-add two SiteConfig fields * Fix config show view Co-authored-by: rhymes <rhymes@hey.com>
44 lines
2.1 KiB
Ruby
44 lines
2.1 KiB
Ruby
module Settings
|
|
class Authentication < RailsSettings::Base
|
|
self.table_name = :settings_authentications
|
|
|
|
# The configuration is cached, change this if you want to force update
|
|
# the cache, or call Settings::Authentication.clear_cache
|
|
cache_prefix { "v1" }
|
|
|
|
field :allow_email_password_login, type: :boolean, default: true
|
|
field :allow_email_password_registration, type: :boolean, default: false
|
|
field :allowed_registration_email_domains, type: :array, default: %w[], validates: {
|
|
valid_domain_csv: true
|
|
}
|
|
field :apple_client_id, type: :string
|
|
field :apple_key_id, type: :string
|
|
field :apple_pem, type: :string
|
|
field :apple_team_id, type: :string
|
|
field :display_email_domain_allow_list_publicly, type: :boolean, default: false
|
|
field :facebook_key, type: :string
|
|
field :facebook_secret, type: :string
|
|
field :github_key, type: :string, default: ApplicationConfig["GITHUB_KEY"]
|
|
field :github_secret, type: :string, default: ApplicationConfig["GITHUB_SECRET"]
|
|
field :invite_only_mode, type: :boolean, default: false
|
|
field :providers, type: :array, default: %w[]
|
|
field :require_captcha_for_email_password_registration, type: :boolean, default: false
|
|
field :twitter_key, type: :string, default: ApplicationConfig["TWITTER_KEY"]
|
|
field :twitter_secret, type: :string, default: ApplicationConfig["TWITTER_SECRET"]
|
|
|
|
# Google ReCATPCHA keys
|
|
field :recaptcha_site_key, type: :string, default: ApplicationConfig["RECAPTCHA_SITE"]
|
|
field :recaptcha_secret_key, type: :string, default: ApplicationConfig["RECAPTCHA_SECRET"]
|
|
|
|
# Apple uses different keys than the usual `PROVIDER_NAME_key` or
|
|
# `PROVIDER_NAME_secret` so these will help the generalized authentication
|
|
# code to work, i.e. https://github.com/forem/forem/blob/master/app/helpers/authentication_helper.rb#L26-L29
|
|
def self.apple_key
|
|
return unless apple_client_id.present? && apple_key_id.present? &&
|
|
apple_pem.present? && apple_team_id.present?
|
|
|
|
"present"
|
|
end
|
|
singleton_class.alias_method(:apple_secret, :apple_key)
|
|
end
|
|
end
|