From d2113777a137bb6740d576cd75061782703f075b Mon Sep 17 00:00:00 2001 From: Eugene Kenny Date: Fri, 22 Dec 2017 22:13:19 +0000 Subject: Allow use_authenticated_message_encryption to be set in new_framework_defaults_5_2.rb Enabling this option in new_framework_defaults_5_2.rb didn't work before, as railtie initializers run before application initializers. Using `respond_to?` to decide whether to set the option wasn't working either, as `ActiveSupport::OrderedOptions` responds to any message. --- activesupport/lib/active_support/message_encryptor.rb | 4 ++-- activesupport/lib/active_support/railtie.rb | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/message_encryptor.rb b/activesupport/lib/active_support/message_encryptor.rb index 27fd061947..5236c776dd 100644 --- a/activesupport/lib/active_support/message_encryptor.rb +++ b/activesupport/lib/active_support/message_encryptor.rb @@ -81,9 +81,9 @@ module ActiveSupport class MessageEncryptor prepend Messages::Rotator::Encryptor - class << self - attr_accessor :use_authenticated_message_encryption #:nodoc: + cattr_accessor :use_authenticated_message_encryption, instance_accessor: false, default: false + class << self def default_cipher #:nodoc: if use_authenticated_message_encryption "aes-256-gcm" diff --git a/activesupport/lib/active_support/railtie.rb b/activesupport/lib/active_support/railtie.rb index 91872e29c8..635d98367e 100644 --- a/activesupport/lib/active_support/railtie.rb +++ b/activesupport/lib/active_support/railtie.rb @@ -10,9 +10,11 @@ module ActiveSupport config.eager_load_namespaces << ActiveSupport initializer "active_support.set_authenticated_message_encryption" do |app| - if app.config.active_support.respond_to?(:use_authenticated_message_encryption) - ActiveSupport::MessageEncryptor.use_authenticated_message_encryption = - app.config.active_support.use_authenticated_message_encryption + config.after_initialize do + unless app.config.active_support.use_authenticated_message_encryption.nil? + ActiveSupport::MessageEncryptor.use_authenticated_message_encryption = + app.config.active_support.use_authenticated_message_encryption + end end end -- cgit v1.2.3