Skip to content

Commit

Permalink
config active support: use :json configuration
Browse files Browse the repository at this point in the history
Because we don't have to think of migrations from a previouse serializer.
  • Loading branch information
otegami committed Aug 28, 2024
1 parent 547f210 commit e5a895d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 30 deletions.
5 changes: 5 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,10 @@ class Application < Rails::Application
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")

# TODO: Remove this configuration at Rails 7.2 because it will be default.
# Use `ActiveSupport::JSON` as the default serializer for `MessageEncryptor`
# and `MessageVerifier` instances.
config.active_support.message_serializer = :json
end
end
30 changes: 0 additions & 30 deletions config/initializers/new_framework_defaults_7_1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,6 @@
#++
Rails.application.config.active_support.raise_on_invalid_cache_expiration_time = true

###
# Specify the default serializer used by `MessageEncryptor` and `MessageVerifier`
# instances.
#
# The legacy default is `:marshal`, which is a potential vector for
# deserialization attacks in cases where a message signing secret has been
# leaked.
#
# In Rails 7.1, the new default is `:json_allow_marshal` which serializes and
# deserializes with `ActiveSupport::JSON`, but can fall back to deserializing
# with `Marshal` so that legacy messages can still be read.
#
# In Rails 7.2, the default will become `:json` which serializes and
# deserializes with `ActiveSupport::JSON` only.
#
# Alternatively, you can choose `:message_pack` or `:message_pack_allow_marshal`,
# which serialize with `ActiveSupport::MessagePack`. `ActiveSupport::MessagePack`
# can roundtrip some Ruby types that are not supported by JSON, and may provide
# improved performance, but it requires the `msgpack` gem.
#
# For more information, see
# https://guides.rubyonrails.org/v7.1/configuring.html#config-active-support-message-serializer
#
# If you are performing a rolling deploy of a Rails 7.1 upgrade, wherein servers
# that have not yet been upgraded must be able to read messages from upgraded
# servers, first deploy without changing the serializer, then set the serializer
# in a subsequent deploy.
#++
Rails.application.config.active_support.message_serializer = :json_allow_marshal

###
# Enable a performance optimization that serializes message data and metadata
# together. This changes the message format, so messages serialized this way
Expand Down

0 comments on commit e5a895d

Please sign in to comment.