Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Ensure values are cached in RequestStore and file only loaded once

Oliver Günthereb4458a02e78
diff --git a/modules/auth_plugins/lib/open_project/plugins/auth_plugin.rb b/modules/auth_plugins/lib/open_project/plugins/auth_plugin.rb
index 217723ff17b..5f9c5aae8ae 100644
--- a/modules/auth_plugins/lib/open_project/plugins/auth_plugin.rb
+++ b/modules/auth_plugins/lib/open_project/plugins/auth_plugin.rb
@@ -51,7 +51,9 @@ module OpenProject::Plugins
end
def self.providers
- filtered_strategies strategies.values.flatten.map(&:call).flatten.map(&:to_hash)
+ RequestStore.fetch(:openproject_omniauth_filtered_strategies) do
+ filtered_strategies strategies.values.flatten.map(&:call).flatten.map(&:to_hash)
+ end
end
def self.filtered_strategies(options)
diff --git a/modules/auth_saml/lib/open_project/auth_saml/engine.rb b/modules/auth_saml/lib/open_project/auth_saml/engine.rb
index 25a46ec19aa..e42b538f832 100644
--- a/modules/auth_saml/lib/open_project/auth_saml/engine.rb
+++ b/modules/auth_saml/lib/open_project/auth_saml/engine.rb
@@ -2,15 +2,22 @@ require 'omniauth-saml'
module OpenProject
module AuthSaml
def self.configuration
- Hash(settings_from_config || settings_from_yaml)
- .with_indifferent_access
- .deep_merge(settings_from_db)
+ RequestStore.fetch(:openproject_omniauth_saml_provider) do
+ @saml_settings ||= load_global_settings!
+ @saml_settings.deep_merge(settings_from_db)
+ end
+ end
+
+ ##
+ # Loads the settings once to avoid accessing the file in each request
+ def self.load_global_settings!
+ Hash(settings_from_config || settings_from_yaml).with_indifferent_access
end
def self.settings_from_db
value = Hash(Setting.plugin_openproject_auth_saml).with_indifferent_access[:providers]
- value.is_a?(Hash) ? value.with_indifferent_access : {}
+ value.is_a?(Hash) ? value : {}
end
def self.settings_from_config