rails/activesupport/lib/active_support
Jonathan Hefner 9fbfd8100b Unify Message{Encryptor,Verifier} serializer config
In #42843 and #42846, several config settings were added to control the
default serializer for `MessageEncryptor` and `MessageVerifier`, and to
provide a migration path from a default `Marshal` serializer to a
default `JSON` serializer:

* `config.active_support.default_message_encryptor_serializer`
  * Supports `:marshal`, `:hybrid`, or `:json`.
* `config.active_support.default_message_verifier_serializer`
  * Supports `:marshal`, `:hybrid`, or `:json`.
* `config.active_support.fallback_to_marshal_deserialization`
  * Affects `:hybrid` for both `MessageEncryptor` and `MessageVerifier`.
* `config.active_support.use_marshal_serialization`
  * Affects `:hybrid` for both `MessageEncryptor` and `MessageVerifier`.

This commit unifies those config settings into a single setting,
`config.active_support.message_serializer`, which supports `:marshal`,
`:json_allow_marshal`, and `:json` values.  So, for example,

  ```ruby
  config.active_support.default_message_encryptor_serializer = :hybrid
  config.active_support.default_message_verifier_serializer = :hybrid
  config.active_support.fallback_to_marshal_deserialization = true
  config.active_support.use_marshal_serialization = false
  ```

becomes

  ```ruby
  config.active_support.message_serializer = :json_allow_marshal
  ```

and

  ```ruby
  config.active_support.default_message_encryptor_serializer = :hybrid
  config.active_support.default_message_verifier_serializer = :hybrid
  config.active_support.fallback_to_marshal_deserialization = false
  config.active_support.use_marshal_serialization = false
  ```

becomes

  ```ruby
  config.active_support.message_serializer = :json
  ```

This commit also replaces `ActiveSupport::JsonWithMarshalFallback` with
`ActiveSupport::Messages::SerializerWithFallback`, which implements a
generic mechanism for serializer fallback.  The `:marshal` serializer
uses this mechanism too, so

  ```ruby
  config.active_support.default_message_encryptor_serializer = :hybrid
  config.active_support.default_message_verifier_serializer = :hybrid
  config.active_support.fallback_to_marshal_deserialization = false
  config.active_support.use_marshal_serialization = true
  ```

becomes

  ```ruby
  config.active_support.message_serializer = :marshal
  ```

Additionally, the logging behavior of `JsonWithMarshalFallback` has been
replaced with notifications which include the names of the intended and
actual serializers, as well as the serialized and deserialized message
data.  This provides a more targeted means of tracking serializer
fallback events.  It also allows the user to "silence" such events, if
desired, without an additional config setting.

All of these changes make it easier to add migration paths for new
serializers such as `ActiveSupport::MessagePack`.
2023-05-08 12:09:45 -05:00
..
cache Log key summary for *_multi cache operations 2023-05-07 12:17:51 -05:00
concurrency Make AbstractAdapter#lock thread local by default 2022-11-23 14:34:40 +01:00
core_ext Object#deep_dup no longer duplicate named classes and modules. 2023-05-02 10:54:46 +02:00
current_attributes Revert "Call Executor#wrap around each test" 2021-10-28 00:35:07 +02:00
dependencies Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
deprecation Simplify reference links [ci-skip] 2023-04-11 16:36:53 -05:00
duration remove extra core_ext/object/blank requires 2022-03-14 21:58:10 -04:00
error_reporter Add raise_on_invalid_cache_expiration_time config to ActiveSupport::Cache::Store 2022-08-30 10:10:28 -05:00
execution_context Extract ActiveSupport::ExecutionContext out of ActiveRecord::QueryLogs 2021-11-10 09:36:02 +01:00
executor Call Executor#wrap around each test 2021-10-28 15:18:29 +02:00
inflector Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
json Fix word case. json -> JSON 2022-09-17 04:11:36 +10:00
locale add zetta to number_to_human_size 2023-03-28 19:50:13 +09:00
log_subscriber Add Oxford commas [ci-skip] 2022-02-21 11:11:11 -06:00
message_pack Support :message_pack as a cache serializer format 2023-05-03 14:22:20 -05:00
messages Unify Message{Encryptor,Verifier} serializer config 2023-05-08 12:09:45 -05:00
multibyte Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
notifications Fix typos for AS::Notifications::Fanout::Handle [ci-skip] 2023-04-16 18:26:50 -05:00
number_helper add zetta to number_to_human_size 2023-03-28 19:50:13 +09:00
testing Merge pull request #47826 from skipkayhil/doc-test-case-aliases 2023-05-05 12:23:31 -04:00
values Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
xml_mini Access JDOM fields as constants in order to be compatibile with JRuby 9.3.x.x 2022-04-21 05:33:59 +03:00
actionable_error.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
all.rb [Active Support] require_relative => require 2017-10-21 22:48:27 +09:00
array_inquirer.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
backtrace_cleaner.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
benchmarkable.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
builder.rb [Active Support] rubocop -a --only Layout/EmptyLineAfterMagicComment 2017-07-11 13:12:32 +09:00
cache.rb Merge pull request #48150 from jonathanhefner/cache-summarize-logged-multi-keys 2023-05-07 22:21:49 -05:00
callbacks.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
code_generator.rb Optimize CurrentAttributes method generation 2021-11-02 15:52:25 +01:00
concern.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
configurable.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
configuration_file.rb Fix ruby-master test suite (Psych 4.0.0) 2021-05-19 14:21:21 +02:00
core_ext.rb Remove deprecated URI.parser 2021-11-19 21:43:23 +00:00
current_attributes.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
dependencies.rb Enable Style/ExplicitBlockArgument cop 2021-09-05 17:06:19 +02:00
deprecation.rb Use "library.name" format in initializer examples 2023-05-07 18:11:16 -04:00
deprecator.rb Use the singleton instance as ActiveSupport deprecator 2023-03-14 17:33:48 +01:00
descendants_tracker.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
digest.rb Standardize nodoc comments 2021-07-29 21:18:07 +00:00
duration.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
encrypted_configuration.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
encrypted_file.rb Hard code serializer for AS::EncryptedFile 2023-01-22 16:26:47 -06:00
environment_inquirer.rb Fix anonymous evals 2023-01-11 11:22:42 +01:00
error_reporter.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
evented_file_update_checker.rb Use original start instead of restart here 2023-03-27 07:59:06 +09:00
execution_context.rb Use IsolatedExecutionState across Active Support 2021-11-19 09:58:15 +01:00
execution_wrapper.rb ActiveSupport::Reloader should not report exception 2022-09-22 17:46:18 +02:00
executor.rb [Active Support] require_relative => require 2017-10-21 22:48:27 +09:00
file_update_checker.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
fork_tracker.rb Make ForkTracker.check! a noop on Ruby 3.1+ 2023-02-16 17:32:38 +01:00
gem_version.rb Fix #version docs and some typos 2022-03-16 01:48:37 +05:30
gzip.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
hash_with_indifferent_access.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
html_safe_translation.rb Extract common behavior of html safe translation to a module 2021-10-12 18:03:46 +00:00
i18n_railtie.rb Make raise_on_missing_translations raise on any missing translation 2023-01-23 10:17:11 -07:00
i18n.rb Inflection support default_locale and fallbacks 2020-12-09 10:06:05 -08:00
inflections.rb [Active Support] require_relative => require 2017-10-21 22:48:27 +09:00
inflector.rb [Active Support] require_relative => require 2017-10-21 22:48:27 +09:00
isolated_execution_state.rb Copy over the IsolatedExecutionState in AC::Live 2022-02-21 11:40:52 +01:00
json.rb [Active Support] require_relative => require 2017-10-21 22:48:27 +09:00
key_generator.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
lazy_load_hooks.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
log_subscriber.rb More Subscriber and LogSubscriber doc uniformity 2023-04-27 22:16:51 -04:00
logger_silence.rb Remove deprecated LoggerSilence constant 2020-10-30 00:25:50 +00:00
logger_thread_safe_level.rb LoggerThreadSafeLevel only impact the receiving logger 2022-11-24 12:39:52 +01:00
logger.rb Revert "Merge pull request #44695 from Edouard-chin/ec-tagger-logger-broadcast" 2022-09-08 16:03:26 +00:00
message_encryptor.rb Unify Message{Encryptor,Verifier} serializer config 2023-05-08 12:09:45 -05:00
message_encryptors.rb Support Message{Encryptors,Verifiers}#rotate block 2022-12-19 16:35:20 -06:00
message_pack.rb Add ActiveSupport::MessagePack 2023-04-17 11:56:06 -05:00
message_verifier.rb Unify Message{Encryptor,Verifier} serializer config 2023-05-08 12:09:45 -05:00
message_verifiers.rb Support Message{Encryptors,Verifiers}#rotate block 2022-12-19 16:35:20 -06:00
multibyte.rb Standardize nodoc comments 2021-07-29 21:18:07 +00:00
notifications.rb Use 2 spaces for identation in ActiveSupport code examples [ci-skip] 2022-11-16 22:44:22 +01:00
number_helper.rb Use 2 spaces for identation in ActiveSupport code examples [ci-skip] 2022-11-16 22:44:22 +01:00
option_merger.rb Fix with_options bug when first argument is a Proc 2022-05-28 16:07:34 -04:00
ordered_hash.rb Fix case of YAML 2022-03-29 16:04:19 +10:00
ordered_options.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
parameter_filter.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
proxy_object.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
rails.rb [ci skip] Small fix to ActiveSupport docs 2019-10-24 09:36:14 +02:00
railtie.rb Unify Message{Encryptor,Verifier} serializer config 2023-05-08 12:09:45 -05:00
reloader.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
rescuable.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
ruby_features.rb Remove feature checking for Class#descendants 2021-12-22 14:12:13 +01:00
secure_compare_rotator.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
security_utils.rb secure_compare: Check byte size instead of length 2021-04-02 12:45:29 -04:00
string_inquirer.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
subscriber.rb More Subscriber and LogSubscriber doc uniformity 2023-04-27 22:16:51 -04:00
syntax_error_proxy.rb Map column information in to ERB templates 2022-10-09 14:52:17 -07:00
tagged_logging.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
test_case.rb Add docs for assert_not TestCase aliases 2023-04-11 19:18:23 -04:00
time_with_zone.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00
time.rb [Active Support] require_relative => require 2017-10-21 22:48:27 +09:00
version.rb Fix #version docs and some typos 2022-03-16 01:48:37 +05:30
xml_mini.rb Add missing headers to Active Support docs [ci-skip] 2023-04-23 16:02:56 +02:00