diff --git a/app/models/concerns/cul/omniauth/abilities.rb b/app/models/concerns/cul/omniauth/abilities.rb index 9e5ee76..5cec7f4 100644 --- a/app/models/concerns/cul/omniauth/abilities.rb +++ b/app/models/concerns/cul/omniauth/abilities.rb @@ -80,7 +80,9 @@ def config @role_proxy_config ||= begin root = (Rails.root.blank?) ? '.' : Rails.root path = File.join(root,'config','roles.yml') - _opts = YAML.load_file(path) + # We'll use YAML loading logic similar to Rails 7, for older and newer psych gem compatibility + # https://github.com/rails/rails/blob/7-1-stable/activesupport/lib/active_support/encrypted_configuration.rb#L99 + _opts = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load_file(path) : YAML.load_file(path) all_config = _opts.fetch("_all_environments", {}) env_config = _opts.fetch(Rails.env, {}) symbolize_hash_keys(all_config.merge(env_config)) diff --git a/lib/cul/omniauth/file_configurable.rb b/lib/cul/omniauth/file_configurable.rb index 0c807ab..818f993 100644 --- a/lib/cul/omniauth/file_configurable.rb +++ b/lib/cul/omniauth/file_configurable.rb @@ -8,7 +8,11 @@ module Cul::Omniauth::FileConfigurable module ClassMethods def cas_configuration_opts @cas_opts ||= begin - _opts = YAML.load_file(File.join(Rails.root,'config','cas.yml'))[Rails.env] || {} + conf_path = File.join(Rails.root,'config','cas.yml') + # We'll use YAML loading logic similar to Rails 7, for older and newer psych gem compatibility + # https://github.com/rails/rails/blob/7-1-stable/activesupport/lib/active_support/encrypted_configuration.rb#L99 + conf = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load_file(conf_path) : YAML.load_file(conf_path) + _opts = conf[Rails.env] || {} _opts = _opts.symbolize_keys _opts end