From b509dec1789702e23100ec1356f258d469a87888 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Wed, 5 Jun 2024 12:04:02 +0100 Subject: [PATCH] make more settings runtime writable the change of which was articifically limited to start-time only --- app/contracts/backups/create_contract.rb | 4 ++-- app/controllers/account_controller.rb | 8 ++++---- app/controllers/admin/backups_controller.rb | 2 +- app/controllers/admin_controller.rb | 2 +- app/controllers/concerns/accounts/redirect_after_login.rb | 4 ++-- app/controllers/concerns/accounts/user_password_change.rb | 2 +- app/controllers/concerns/password_confirmation.rb | 2 +- app/controllers/help_controller.rb | 2 +- app/controllers/ldap_auth_sources_controller.rb | 2 +- app/controllers/users_controller.rb | 2 +- app/helpers/backup_helper.rb | 4 ++-- app/helpers/homescreen_helper.rb | 4 ++-- app/helpers/users_helper.rb | 2 +- app/mailers/user_mailer.rb | 2 +- app/models/backup.rb | 4 ++-- app/models/ldap_auth_source.rb | 2 +- app/models/permitted_params/allowed_settings.rb | 2 +- app/models/token/backup.rb | 2 +- app/models/user.rb | 6 +++--- app/models/user_preference.rb | 2 +- app/services/ldap/base_service.rb | 4 ++-- app/services/users/logout_service.rb | 2 +- app/uploaders/fog_file_uploader.rb | 2 +- app/views/account/_auth_providers.html.erb | 2 +- app/views/account/login.html.erb | 2 +- .../admin/settings/authentication_settings/show.html.erb | 6 +++--- app/views/users/form/authentication/_internal.html.erb | 2 +- .../users/form/authentication/_internal_password.html.erb | 2 +- app/workers/attachments/cleanup_uncontainered_job.rb | 2 +- app/workers/attachments/extract_fulltext_job.rb | 2 +- app/workers/exports/cleanup_outdated_job.rb | 4 ++-- app/workers/ldap/synchronization_job.rb | 2 +- config/initializers/menus.rb | 4 ++-- config/initializers/permissions.rb | 2 +- lib/api/helpers/attachment_renderer.rb | 4 ++-- lib/api/v3/backups/backups_api.rb | 2 +- lib/open_project/full_text_search.rb | 2 +- lib/redmine/menu_manager/top_menu_helper.rb | 2 +- lib/tasks/backup.rake | 2 +- .../strategies/warden/basic_auth_failure.rb | 2 +- .../authentication/strategies/warden/global_basic_auth.rb | 2 +- .../authentication/strategies/warden/user_basic_auth.rb | 2 +- modules/avatars/app/helpers/avatar_helper.rb | 2 +- .../bim/spec/requests/api/bcf/v2_1/viewpoints_api_spec.rb | 2 +- .../app/workers/ldap_groups/synchronization_job.rb | 2 +- modules/reporting/app/models/cost_query/cache.rb | 2 +- .../reporting/spec/lib/open_project/configuration_spec.rb | 4 ++-- .../storages/cleanup_uncontainered_file_links_job.rb | 2 +- spec/factories/token_factory.rb | 2 +- spec/models/attachment_spec.rb | 2 +- .../v3/attachments/attachment_resource_shared_examples.rb | 4 ++-- 51 files changed, 69 insertions(+), 69 deletions(-) diff --git a/app/contracts/backups/create_contract.rb b/app/contracts/backups/create_contract.rb index 17bc328d8a46..86b1f0872eba 100644 --- a/app/contracts/backups/create_contract.rb +++ b/app/contracts/backups/create_contract.rb @@ -49,7 +49,7 @@ def backup_token def check_waiting_period(token) if token.waiting? - valid_at = token.created_at + OpenProject::Configuration.backup_initial_waiting_period + valid_at = token.created_at + Setting.backup_initial_waiting_period hours = ((valid_at - Time.zone.now) / 60.0 / 60.0).round errors.add :base, :token_cooldown, message: I18n.t("backup.error.token_cooldown", hours:) @@ -57,7 +57,7 @@ def check_waiting_period(token) end def backup_limit - limit = OpenProject::Configuration.backup_daily_limit + limit = Setting.backup_daily_limit if Backup.where("created_at >= ?", Time.zone.today).count > limit errors.add :base, :limit_reached, message: I18n.t("backup.error.limit_reached", limit:) end diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 700a0c132ed2..53a7eefc6680 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -146,7 +146,7 @@ def register end def allow_registration? - allow = Setting::SelfRegistration.enabled? && !OpenProject::Configuration.disable_password_login? + allow = Setting::SelfRegistration.enabled? && !Setting.disable_password_login? invited = session[:invitation_token].present? get = request.get? && allow @@ -156,7 +156,7 @@ def allow_registration? end def allow_lost_password_recovery? - Setting.lost_password? && !OpenProject::Configuration.disable_password_login? + Setting.lost_password? && !Setting.disable_password_login? end # Token based account activation @@ -234,7 +234,7 @@ def activate_invited(token) def activate_user(user) if omniauth_direct_login? direct_login user - elsif OpenProject::Configuration.disable_password_login? + elsif Setting.disable_password_login? flash[:notice] = I18n.t("account.omniauth_login") redirect_to signin_path @@ -401,7 +401,7 @@ def direct_login(user) end def authenticate_user - if OpenProject::Configuration.disable_password_login? + if Setting.disable_password_login? render_404 else password_authentication(params[:username]&.strip, params[:password]) diff --git a/app/controllers/admin/backups_controller.rb b/app/controllers/admin/backups_controller.rb index b156aef9a081..c4c2fec832d0 100644 --- a/app/controllers/admin/backups_controller.rb +++ b/app/controllers/admin/backups_controller.rb @@ -85,7 +85,7 @@ def show_local_breadcrumb end def check_enabled - render_404 unless OpenProject::Configuration.backup_enabled? + render_404 unless Setting.backup_enabled? end private diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 88eb45a947e4..970c6c3f810a 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -105,7 +105,7 @@ def show_local_breadcrumb private def hidden_admin_menu_items - OpenProject::Configuration.hidden_menu_items[:admin_menu.to_s] || [] + Setting.hidden_menu_items[:admin_menu.to_s] || [] end def plaintext_extraction_checks diff --git a/app/controllers/concerns/accounts/redirect_after_login.rb b/app/controllers/concerns/accounts/redirect_after_login.rb index e5bcc7e9a359..62d1b854bacd 100644 --- a/app/controllers/concerns/accounts/redirect_after_login.rb +++ b/app/controllers/concerns/accounts/redirect_after_login.rb @@ -43,7 +43,7 @@ def redirect_after_login(user) end def default_redirect - if (url = OpenProject::Configuration.after_login_default_redirect_url) + if (url = Setting.after_login_default_redirect_url) redirect_back_or_default url else redirect_back_or_default my_page_path @@ -51,7 +51,7 @@ def default_redirect end def first_login_redirect - if (url = OpenProject::Configuration.after_first_login_redirect_url) + if (url = Setting.after_first_login_redirect_url) redirect_back_or_default url else redirect_back_or_default home_url(first_time_user: true) diff --git a/app/controllers/concerns/accounts/user_password_change.rb b/app/controllers/concerns/accounts/user_password_change.rb index 1ce7f02cbd4e..d83631a8a0e6 100644 --- a/app/controllers/concerns/accounts/user_password_change.rb +++ b/app/controllers/concerns/accounts/user_password_change.rb @@ -34,7 +34,7 @@ module Accounts::UserPasswordChange # to change the password. # When making changes here, also check MyController.change_password def change_password_flow(user:, params:, update_legacy: true, show_user_name: false) - return render_404 if OpenProject::Configuration.disable_password_login? + return render_404 if Setting.disable_password_login? # A JavaScript hides the force_password_change field for external # auth sources in the admin UI, so this shouldn't normally happen. diff --git a/app/controllers/concerns/password_confirmation.rb b/app/controllers/concerns/password_confirmation.rb index 79ecc8e1446f..0687aca93e0b 100644 --- a/app/controllers/concerns/password_confirmation.rb +++ b/app/controllers/concerns/password_confirmation.rb @@ -45,7 +45,7 @@ def check_password_confirmation # Returns whether password confirmation has been enabled globally # AND the current user is internally authenticated. def password_confirmation_required? - OpenProject::Configuration.internal_password_confirmation? && + Setting.internal_password_confirmation? && !User.current.uses_external_authentication? end end diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index 2af67cb280a4..9499b0f3bcf8 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -33,7 +33,7 @@ def keyboard_shortcuts def text_formatting default_link = OpenProject::Static::Links[:text_formatting][:href] - help_link = OpenProject::Configuration.force_formatting_help_link.presence || default_link + help_link = Setting.force_formatting_help_link.presence || default_link redirect_to help_link end diff --git a/app/controllers/ldap_auth_sources_controller.rb b/app/controllers/ldap_auth_sources_controller.rb index 172a358af681..75126a010b1c 100644 --- a/app/controllers/ldap_auth_sources_controller.rb +++ b/app/controllers/ldap_auth_sources_controller.rb @@ -119,6 +119,6 @@ def show_local_breadcrumb end def block_if_password_login_disabled - render_404 if OpenProject::Configuration.disable_password_login? + render_404 if Setting.disable_password_login? end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 1a599d96d232..1c459eec5bbc 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -295,7 +295,7 @@ def my_or_admin_layout end def set_password?(params) - params[:user][:password].present? && !OpenProject::Configuration.disable_password_choice? + params[:user][:password].present? && !Setting.disable_password_choice? end protected diff --git a/app/helpers/backup_helper.rb b/app/helpers/backup_helper.rb index c29f2f6e7161..96d8b828290b 100644 --- a/app/helpers/backup_helper.rb +++ b/app/helpers/backup_helper.rb @@ -49,7 +49,7 @@ def allow_instant_backup_for_user?(user, date: instant_backup_threshold_date) end def instant_backup_threshold_date - DateTime.now - OpenProject::Configuration.backup_initial_waiting_period + DateTime.now - Setting.backup_initial_waiting_period end def just_installed_openproject?(after: instant_backup_threshold_date) @@ -71,7 +71,7 @@ def create_backup_token(user: current_user) end def notify_user_and_admins(user, backup_token:) - waiting_period = backup_token.waiting? && OpenProject::Configuration.backup_initial_waiting_period + waiting_period = backup_token.waiting? && Setting.backup_initial_waiting_period users = ([user] + User.admin.active).uniq users.each do |recipient| diff --git a/app/helpers/homescreen_helper.rb b/app/helpers/homescreen_helper.rb index e0c624877b78..19db47144658 100644 --- a/app/helpers/homescreen_helper.rb +++ b/app/helpers/homescreen_helper.rb @@ -54,12 +54,12 @@ def static_link_to(key) ## # Determine whether we should render the links on homescreen? def show_homescreen_links? - EnterpriseToken.show_banners? || OpenProject::Configuration.show_community_links? + EnterpriseToken.show_banners? || Setting.show_community_links? end ## # Determine whether we should render the onboarding modal def show_onboarding_modal? - OpenProject::Configuration.onboarding_enabled? && params[:first_time_user] + Setting.onboarding_enabled? && params[:first_time_user] end end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 786242f9bc8d..529fc4332259 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -142,6 +142,6 @@ def allowed_management_user_profile_path(user) end def can_users_have_auth_source? - LdapAuthSource.any? && !OpenProject::Configuration.disable_password_login? + LdapAuthSource.any? && !Setting.disable_password_login? end end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 3838cecfdcfb..f84678e68265 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -45,7 +45,7 @@ def backup_ready(user) send_localized_mail(user) { I18n.t(:mail_subject_backup_ready) } end - def backup_token_reset(recipient, user:, waiting_period: OpenProject::Configuration.backup_initial_waiting_period) + def backup_token_reset(recipient, user:, waiting_period: Setting.backup_initial_waiting_period) @admin_notification = recipient != user # notification for other admins rather than oneself @user_login = user.login @waiting_period = waiting_period diff --git a/app/models/backup.rb b/app/models/backup.rb index be4039eedbe7..d3943036bb76 100644 --- a/app/models/backup.rb +++ b/app/models/backup.rb @@ -5,7 +5,7 @@ def permission end def include_attachments? - val = OpenProject::Configuration.backup_include_attachments + val = Setting.backup_include_attachments val.nil? ? true : val.to_s.to_bool # default to true end @@ -14,7 +14,7 @@ def include_attachments? # Don't include attachments in archive if they are larger than # this value combined. def attachment_size_max_sum_mb - (OpenProject::Configuration.backup_attachment_size_max_sum_mb.presence || 1024).to_i + (Setting.backup_attachment_size_max_sum_mb.presence || 1024).to_i end def attachments_query diff --git a/app/models/ldap_auth_source.rb b/app/models/ldap_auth_source.rb index a2a4920b6ac9..ae46c2ab45f8 100644 --- a/app/models/ldap_auth_source.rb +++ b/app/models/ldap_auth_source.rb @@ -235,7 +235,7 @@ def ldap_connection_options { host:, port:, - force_no_page: OpenProject::Configuration.ldap_force_no_page, + force_no_page: Setting.ldap_force_no_page, encryption: ldap_encryption } end diff --git a/app/models/permitted_params/allowed_settings.rb b/app/models/permitted_params/allowed_settings.rb index ce1e2b1de59d..379f47cb6492 100644 --- a/app/models/permitted_params/allowed_settings.rb +++ b/app/models/permitted_params/allowed_settings.rb @@ -70,7 +70,7 @@ def init! add_restriction!( keys: password_keys, - condition: -> { OpenProject::Configuration.disable_password_login? } + condition: -> { Setting.disable_password_login? } ) add_restriction!( diff --git a/app/models/token/backup.rb b/app/models/token/backup.rb index c74271720cbb..77aba65cc3b6 100644 --- a/app/models/token/backup.rb +++ b/app/models/token/backup.rb @@ -31,7 +31,7 @@ class Backup < HashedToken def ready? return false if created_at.nil? - created_at.since(OpenProject::Configuration.backup_initial_waiting_period).past? + created_at.since(Setting.backup_initial_waiting_period).past? end def waiting? diff --git a/app/models/user.rb b/app/models/user.rb index ca6f7e0e1924..9a576f0bcb31 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -213,7 +213,7 @@ def self.try_to_login(login, password, session = nil) def self.try_authentication_for_existing_user(user, password, session = nil) activate_user! user, session if session - return nil if !user.active? || OpenProject::Configuration.disable_password_login? + return nil if !user.active? || Setting.disable_password_login? if user.ldap_auth_source # user has an external authentication method @@ -242,7 +242,7 @@ def self.activate_user!(user, session) # Tries to authenticate with available sources and creates user on success def self.try_authentication_and_create_user(login, password) - return nil if OpenProject::Configuration.disable_password_login? + return nil if Setting.disable_password_login? user = LdapAuthSource.authenticate(login, password) @@ -344,7 +344,7 @@ def check_password?(clear_password, update_legacy: true) # Does the backend storage allow this user to change their password? def change_password_allowed? return false if uses_external_authentication? || - OpenProject::Configuration.disable_password_login? + Setting.disable_password_login? ldap_auth_source_id.blank? end diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb index b242b7771cdc..37f5519dd4c1 100644 --- a/app/models/user_preference.rb +++ b/app/models/user_preference.rb @@ -79,7 +79,7 @@ def []=(attr_name, value) end def comments_sorting - settings.fetch(:comments_sorting, OpenProject::Configuration.default_comment_sort_order) + settings.fetch(:comments_sorting, Setting.default_comment_sort_order) end def comments_in_reverse_order? diff --git a/app/services/ldap/base_service.rb b/app/services/ldap/base_service.rb index a2afb8b3642e..3d94d1fb3c53 100644 --- a/app/services/ldap/base_service.rb +++ b/app/services/ldap/base_service.rb @@ -72,7 +72,7 @@ def try_to_create(attrs) ## # Locks the given user if this is what the sync service should do. def lock_user!(user) - if OpenProject::Configuration.ldap_users_sync_status? + if Setting.ldap_users_sync_status? Rails.logger.info { "Could not find user #{user.login} in #{ldap.name}. Locking the user." } user.update_column(:status, Principal.statuses[:locked]) else @@ -85,7 +85,7 @@ def lock_user!(user) ## # Activates the given user if this is what the sync service should do. def activate_user!(user) - if OpenProject::Configuration.ldap_users_sync_status? + if Setting.ldap_users_sync_status? Rails.logger.info { "Activating #{user.login} due to it being synced from LDAP #{ldap.name}." } user.update_column(:status, Principal.statuses[:active]) else diff --git a/app/services/users/logout_service.rb b/app/services/users/logout_service.rb index bb7d58e0a0aa..6e1d8ddd02c3 100644 --- a/app/services/users/logout_service.rb +++ b/app/services/users/logout_service.rb @@ -38,7 +38,7 @@ def initialize(controller:) def call!(user) OpenProject.logger.info { "Logging out ##{user.id}" } - if OpenProject::Configuration.drop_old_sessions_on_logout? + if Setting.drop_old_sessions_on_logout? remove_all_autologin_tokens! user remove_all_sessions! user else diff --git a/app/uploaders/fog_file_uploader.rb b/app/uploaders/fog_file_uploader.rb index 9349402b6b33..ac7734a02e6c 100644 --- a/app/uploaders/fog_file_uploader.rb +++ b/app/uploaders/fog_file_uploader.rb @@ -114,7 +114,7 @@ def set_content_disposition!(url_options, options:) def set_expires_at!(url_options, options:) if options[:expires_in].present? - expires = [options[:expires_in], OpenProject::Configuration.fog_download_url_expires_in].min + expires = [options[:expires_in], Setting.fog_download_url_expires_in].min url_options[:expire_at] = ::Fog::Time.now + expires end diff --git a/app/views/account/_auth_providers.html.erb b/app/views/account/_auth_providers.html.erb index b2bcbec89e0f..3461b6b2cd23 100644 --- a/app/views/account/_auth_providers.html.erb +++ b/app/views/account/_auth_providers.html.erb @@ -37,7 +37,7 @@ See COPYRIGHT and LICENSE files for more details. # * https://community.openproject.org/work_packages/7192 # * http://stackoverflow.com/questions/13112430/find-loaded-providers-for-omniauth auth_provider_html = call_hook :view_account_login_auth_provider -no_pwd = OpenProject::Configuration.disable_password_login? +no_pwd = Setting.disable_password_login? pclass = no_pwd ? 'no-pwd' : '' wclass = local_assigns[:wide] ? 'wide' : '' %> diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb index c07defe494a9..8b4885070994 100644 --- a/app/views/account/login.html.erb +++ b/app/views/account/login.html.erb @@ -34,7 +34,7 @@ See COPYRIGHT and LICENSE files for more details.

<%= I18n.t(:label_login) %>


- <% unless OpenProject::Configuration.disable_password_login? %> + <% unless Setting.disable_password_login? %> <%= render partial: 'password_login_form' %> <% end %> <%= render partial: 'auth_providers' %> diff --git a/app/views/admin/settings/authentication_settings/show.html.erb b/app/views/admin/settings/authentication_settings/show.html.erb index afe95a411bea..79f5f13559d3 100644 --- a/app/views/admin/settings/authentication_settings/show.html.erb +++ b/app/views/admin/settings/authentication_settings/show.html.erb @@ -59,7 +59,7 @@ See COPYRIGHT and LICENSE files for more details.
<%= I18n.t(:passwords, scope: [:settings]) %> - <% if !OpenProject::Configuration.disable_password_login? %> + <% if !Setting.disable_password_login? %>
<%= setting_text_field :password_min_length, size: 6, container_class: '-xslim' %>
<% rules = OpenProject::Passwords::Evaluator.known_rules.map do |rule| @@ -91,7 +91,7 @@ See COPYRIGHT and LICENSE files for more details. <% end %>
- <% unless OpenProject::Configuration.disable_password_login? %> + <% unless Setting.disable_password_login? %>
<%= I18n.t(:brute_force_prevention, scope: [:settings]) %>
<%= setting_text_field :brute_force_block_after_failed_logins, container_class: '-xslim' %> @@ -127,7 +127,7 @@ See COPYRIGHT and LICENSE files for more details.
<%= setting_check_box :log_requesting_user %>
- <% unless OpenProject::Configuration.disable_password_login? %> + <% unless Setting.disable_password_login? %>
<%= link_to t(:label_ldap_authentication), {controller: '/ldap_auth_sources', action: 'index'}, class: 'icon icon-server-key' %>
diff --git a/app/views/users/form/authentication/_internal.html.erb b/app/views/users/form/authentication/_internal.html.erb index e65ba9f8cb9b..b7eca7875d9a 100644 --- a/app/views/users/form/authentication/_internal.html.erb +++ b/app/views/users/form/authentication/_internal.html.erb @@ -1,4 +1,4 @@ -<% if OpenProject::Configuration.disable_password_login? %> +<% if Setting.disable_password_login? %>
<%= styled_label_tag nil, I18n.t(:warning) %> diff --git a/app/views/users/form/authentication/_internal_password.html.erb b/app/views/users/form/authentication/_internal_password.html.erb index b080f7818b48..0d034c50d6db 100644 --- a/app/views/users/form/authentication/_internal_password.html.erb +++ b/app/views/users/form/authentication/_internal_password.html.erb @@ -21,7 +21,7 @@
- <% unless OpenProject::Configuration.disable_password_choice? %> + <% unless Setting.disable_password_choice? %>
<%= f.password_field :password, required: @user.new_record?, diff --git a/app/workers/attachments/cleanup_uncontainered_job.rb b/app/workers/attachments/cleanup_uncontainered_job.rb index 5b0dc599ef53..e71c6ac3a6a2 100644 --- a/app/workers/attachments/cleanup_uncontainered_job.rb +++ b/app/workers/attachments/cleanup_uncontainered_job.rb @@ -47,7 +47,7 @@ def too_old attachment_table = Attachment.arel_table attachment_table[:created_at] - .lteq(Time.zone.now - OpenProject::Configuration.attachments_grace_period.minutes) + .lteq(Time.zone.now - Setting.attachments_grace_period.minutes) .to_sql end end diff --git a/app/workers/attachments/extract_fulltext_job.rb b/app/workers/attachments/extract_fulltext_job.rb index a9379778bd87..a142dd98ed4c 100644 --- a/app/workers/attachments/extract_fulltext_job.rb +++ b/app/workers/attachments/extract_fulltext_job.rb @@ -36,7 +36,7 @@ def perform(attachment_id) @text = nil @file = nil @filename = nil - @language = OpenProject::Configuration.main_content_language + @language = Setting.main_content_language return unless OpenProject::Database.allows_tsv? return unless @attachment = find_attachment(attachment_id) diff --git a/app/workers/exports/cleanup_outdated_job.rb b/app/workers/exports/cleanup_outdated_job.rb index ad081368538a..879abc051677 100644 --- a/app/workers/exports/cleanup_outdated_job.rb +++ b/app/workers/exports/cleanup_outdated_job.rb @@ -30,12 +30,12 @@ class Exports::CleanupOutdatedJob < ApplicationJob queue_with_priority :low def self.perform_after_grace - set(wait: OpenProject::Configuration.attachments_grace_period.minutes).perform_later + set(wait: Setting.attachments_grace_period.minutes).perform_later end def perform Export - .where("created_at <= ?", Time.current - OpenProject::Configuration.attachments_grace_period.minutes) + .where("created_at <= ?", Time.current - Setting.attachments_grace_period.minutes) .destroy_all end end diff --git a/app/workers/ldap/synchronization_job.rb b/app/workers/ldap/synchronization_job.rb index a100d5b87898..769cc7059708 100644 --- a/app/workers/ldap/synchronization_job.rb +++ b/app/workers/ldap/synchronization_job.rb @@ -35,7 +35,7 @@ def perform private def run_user_sync - return if OpenProject::Configuration.ldap_users_disable_sync_job? + return if Setting.ldap_users_disable_sync_job? ::LdapAuthSource.find_each do |ldap| Rails.logger.info { "[LDAP groups] Synchronizing users for LDAP connection #{ldap.name}" } diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb index 160e294296d9..10ff595f0770 100644 --- a/config/initializers/menus.rb +++ b/config/initializers/menus.rb @@ -467,7 +467,7 @@ menu.push :ldap_authentication, { controller: "/ldap_auth_sources", action: "index" }, - if: Proc.new { User.current.admin? && !OpenProject::Configuration.disable_password_login? }, + if: Proc.new { User.current.admin? && !Setting.disable_password_login? }, parent: :authentication, caption: :label_ldap_auth_source_plural, html: { class: "server_authentication" }, @@ -494,7 +494,7 @@ menu.push :backups, { controller: "/admin/backups", action: "show" }, - if: Proc.new { OpenProject::Configuration.backup_enabled? && User.current.allowed_globally?(Backup.permission) }, + if: Proc.new { Setting.backup_enabled? && User.current.allowed_globally?(Backup.permission) }, caption: :label_backup, last: true, icon: "save" diff --git a/config/initializers/permissions.rb b/config/initializers/permissions.rb index c92ee82c1f11..60ea55dbf865 100644 --- a/config/initializers/permissions.rb +++ b/config/initializers/permissions.rb @@ -49,7 +49,7 @@ }, permissible_on: :global, require: :loggedin, - enabled: -> { OpenProject::Configuration.backup_enabled? } + enabled: -> { Setting.backup_enabled? } map.permission :create_user, { diff --git a/lib/api/helpers/attachment_renderer.rb b/lib/api/helpers/attachment_renderer.rb index 25ae274267be..7c637e69e88c 100644 --- a/lib/api/helpers/attachment_renderer.rb +++ b/lib/api/helpers/attachment_renderer.rb @@ -125,7 +125,7 @@ def set_cache_headers!(seconds = nil) def fog_cache_seconds [ 0, - OpenProject::Configuration.fog_download_url_expires_in.to_i - 10 + Setting.fog_download_url_expires_in.to_i - 10 ].max end @@ -140,7 +140,7 @@ def avatar_link_expires_in end def avatar_link_expiry_seconds - @avatar_link_expiry_seconds ||= OpenProject::Configuration.avatar_link_expiry_seconds.to_i + @avatar_link_expiry_seconds ||= Setting.avatar_link_expiry_seconds.to_i end end end diff --git a/lib/api/v3/backups/backups_api.rb b/lib/api/v3/backups/backups_api.rb index c872937f96a9..736cab65ba5a 100644 --- a/lib/api/v3/backups/backups_api.rb +++ b/lib/api/v3/backups/backups_api.rb @@ -32,7 +32,7 @@ module Backups class BackupsAPI < ::API::OpenProjectAPI resources :backups do before do - raise API::Errors::NotFound unless OpenProject::Configuration.backup_enabled? + raise API::Errors::NotFound unless Setting.backup_enabled? end after_validation do diff --git a/lib/open_project/full_text_search.rb b/lib/open_project/full_text_search.rb index 6007e2809997..afe6b940f8ef 100644 --- a/lib/open_project/full_text_search.rb +++ b/lib/open_project/full_text_search.rb @@ -37,7 +37,7 @@ def self.tsv_where(table_name, column_name, value, concatenation: :and, normaliz query = tokenize(value, concatenation, normalization) return if query.blank? - language = OpenProject::Configuration.main_content_language + language = Setting.main_content_language ActiveRecord::Base.send( :sanitize_sql_array, ["#{column} @@ to_tsquery(?, ?)", diff --git a/lib/redmine/menu_manager/top_menu_helper.rb b/lib/redmine/menu_manager/top_menu_helper.rb index 1a8f5498bda5..86b4339cebcf 100644 --- a/lib/redmine/menu_manager/top_menu_helper.rb +++ b/lib/redmine/menu_manager/top_menu_helper.rb @@ -153,7 +153,7 @@ def render_user_drop_down(items) def render_login_partial partial = - if OpenProject::Configuration.disable_password_login? + if Setting.disable_password_login? "account/omniauth_login" else "account/login" diff --git a/lib/tasks/backup.rake b/lib/tasks/backup.rake index 71d3cbd3f4b3..2fb02ca566dc 100644 --- a/lib/tasks/backup.rake +++ b/lib/tasks/backup.rake @@ -87,7 +87,7 @@ namespace :backup do desc "Allows user-initiated backups right away, skipping the cooldown period after a new token was created." task allow_now: :environment do - date = DateTime.now - OpenProject::Configuration.backup_initial_waiting_period + date = DateTime.now - Setting.backup_initial_waiting_period Token::Backup.where("created_at > ?", date).each do |token| token.update_column :created_at, date diff --git a/lib_static/open_project/authentication/strategies/warden/basic_auth_failure.rb b/lib_static/open_project/authentication/strategies/warden/basic_auth_failure.rb index 16637ed7022d..387541e06425 100644 --- a/lib_static/open_project/authentication/strategies/warden/basic_auth_failure.rb +++ b/lib_static/open_project/authentication/strategies/warden/basic_auth_failure.rb @@ -7,7 +7,7 @@ module Warden # indicate that invalid basic auth credentials were provided. class BasicAuthFailure < ::Warden::Strategies::BasicAuth def valid? - OpenProject::Configuration.apiv3_enable_basic_auth? && super + Setting.apiv3_enable_basic_auth? && super end def authenticate_user(_username, _password) diff --git a/lib_static/open_project/authentication/strategies/warden/global_basic_auth.rb b/lib_static/open_project/authentication/strategies/warden/global_basic_auth.rb index a28ebca96088..ba2dc0dd1306 100644 --- a/lib_static/open_project/authentication/strategies/warden/global_basic_auth.rb +++ b/lib_static/open_project/authentication/strategies/warden/global_basic_auth.rb @@ -70,7 +70,7 @@ def self.password ## # Only valid if global basic auth is configured and tried. def valid? - OpenProject::Configuration.apiv3_enable_basic_auth? && + Setting.apiv3_enable_basic_auth? && self.class.configuration? && super && username == self.class.user diff --git a/lib_static/open_project/authentication/strategies/warden/user_basic_auth.rb b/lib_static/open_project/authentication/strategies/warden/user_basic_auth.rb index 04b12cc103b5..110060a798e1 100644 --- a/lib_static/open_project/authentication/strategies/warden/user_basic_auth.rb +++ b/lib_static/open_project/authentication/strategies/warden/user_basic_auth.rb @@ -17,7 +17,7 @@ def self.user end def valid? - OpenProject::Configuration.apiv3_enable_basic_auth? && + Setting.apiv3_enable_basic_auth? && super && username == self.class.user end diff --git a/modules/avatars/app/helpers/avatar_helper.rb b/modules/avatars/app/helpers/avatar_helper.rb index 23a72db9b623..766ff02076b2 100644 --- a/modules/avatars/app/helpers/avatar_helper.rb +++ b/modules/avatars/app/helpers/avatar_helper.rb @@ -125,7 +125,7 @@ def merge_default_avatar_options(user, options) def default_gravatar_options { secure: OpenProject::Configuration.https?, - default: OpenProject::Configuration.gravatar_fallback_image + default: Setting.gravatar_fallback_image } end diff --git a/modules/bim/spec/requests/api/bcf/v2_1/viewpoints_api_spec.rb b/modules/bim/spec/requests/api/bcf/v2_1/viewpoints_api_spec.rb index f843c7c467c2..6f24661eadf8 100644 --- a/modules/bim/spec/requests/api/bcf/v2_1/viewpoints_api_spec.rb +++ b/modules/bim/spec/requests/api/bcf/v2_1/viewpoints_api_spec.rb @@ -203,7 +203,7 @@ expect(subject.status).to eq 200 expect(subject.headers["Content-Type"]).to eq "image/png" - max_age = OpenProject::Configuration.fog_download_url_expires_in - 10 + max_age = Setting.fog_download_url_expires_in - 10 expect(subject.headers["Cache-Control"]).to eq "public, max-age=#{max_age}" expect(subject.headers["Expires"]).to be_present diff --git a/modules/ldap_groups/app/workers/ldap_groups/synchronization_job.rb b/modules/ldap_groups/app/workers/ldap_groups/synchronization_job.rb index afde20b08a36..f053ad2403e5 100644 --- a/modules/ldap_groups/app/workers/ldap_groups/synchronization_job.rb +++ b/modules/ldap_groups/app/workers/ldap_groups/synchronization_job.rb @@ -36,7 +36,7 @@ def perform end def skipped? - OpenProject::Configuration.ldap_groups_disable_sync_job? + Setting.ldap_groups_disable_sync_job? end end end diff --git a/modules/reporting/app/models/cost_query/cache.rb b/modules/reporting/app/models/cost_query/cache.rb index a3778c9ca3ba..908e89999c34 100644 --- a/modules/reporting/app/models/cost_query/cache.rb +++ b/modules/reporting/app/models/cost_query/cache.rb @@ -70,7 +70,7 @@ def fetch_current_custom_field_count end def caching_disabled? - !OpenProject::Configuration.cost_reporting_cache_filter_classes + !Setting.cost_reporting_cache_filter_classes end def reset_required? diff --git a/modules/reporting/spec/lib/open_project/configuration_spec.rb b/modules/reporting/spec/lib/open_project/configuration_spec.rb index 34f7d4792ff4..80be5f7bd7ae 100644 --- a/modules/reporting/spec/lib/open_project/configuration_spec.rb +++ b/modules/reporting/spec/lib/open_project/configuration_spec.rb @@ -31,11 +31,11 @@ RSpec.describe "OpenProject::Configuration" do describe ".cost_reporting_cache_filter_classes" do it "is a true by default via the method" do - expect(OpenProject::Configuration.cost_reporting_cache_filter_classes).to be_truthy + expect(Setting.cost_reporting_cache_filter_classes).to be_truthy end it "is true by default via the hash" do - expect(OpenProject::Configuration["cost_reporting_cache_filter_classes"]).to be_truthy + expect(Setting["cost_reporting_cache_filter_classes"]).to be_truthy end end end diff --git a/modules/storages/app/workers/storages/cleanup_uncontainered_file_links_job.rb b/modules/storages/app/workers/storages/cleanup_uncontainered_file_links_job.rb index cc5dbf1048c1..e5fe363f2fb9 100644 --- a/modules/storages/app/workers/storages/cleanup_uncontainered_file_links_job.rb +++ b/modules/storages/app/workers/storages/cleanup_uncontainered_file_links_job.rb @@ -32,7 +32,7 @@ class Storages::CleanupUncontaineredFileLinksJob < ApplicationJob def perform Storages::FileLink .where(container: nil) - .where("created_at <= ?", Time.current - OpenProject::Configuration.attachments_grace_period.minutes) + .where("created_at <= ?", Time.current - Setting.attachments_grace_period.minutes) .delete_all end end diff --git a/spec/factories/token_factory.rb b/spec/factories/token_factory.rb index 110738886808..ab83afa738b9 100644 --- a/spec/factories/token_factory.rb +++ b/spec/factories/token_factory.rb @@ -53,7 +53,7 @@ user after(:build) do |token| - token.created_at = DateTime.now - OpenProject::Configuration.backup_initial_waiting_period + token.created_at = DateTime.now - Setting.backup_initial_waiting_period end trait :with_waiting_period do diff --git a/spec/models/attachment_spec.rb b/spec/models/attachment_spec.rb index fa781fb543df..509c149b3402 100644 --- a/spec/models/attachment_spec.rb +++ b/spec/models/attachment_spec.rb @@ -242,7 +242,7 @@ let(:url_options) { { expires_in: 1.year } } it "uses the allowed max" do - expect(query).to include "X-Amz-Expires=#{OpenProject::Configuration.fog_download_url_expires_in}" + expect(query).to include "X-Amz-Expires=#{Setting.fog_download_url_expires_in}" end end end diff --git a/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb b/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb index cc32297a87d6..31c9c7056db9 100644 --- a/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb +++ b/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb @@ -456,7 +456,7 @@ def request! expect(subject.headers["Content-Type"]) .to eql expected_content_type - max_age = OpenProject::Configuration.fog_download_url_expires_in.to_i - 10 + max_age = Setting.fog_download_url_expires_in.to_i - 10 expect(subject.headers["Cache-Control"]).to eq "public, max-age=#{max_age}" expect(subject.headers["Expires"]).to be_present @@ -524,7 +524,7 @@ def request! expect(subject.headers["Location"]) .to eql external_url - max_age = OpenProject::Configuration.fog_download_url_expires_in.to_i - 10 + max_age = Setting.fog_download_url_expires_in.to_i - 10 expect(subject.headers["Cache-Control"]).to eq "public, max-age=#{max_age}" expect(subject.headers["Expires"]).to be_present