Skip to content

Commit

Permalink
key hash rotate for activeStorage keep mini magic, load defaults for 7 (
Browse files Browse the repository at this point in the history
  • Loading branch information
michelson committed Nov 3, 2023
1 parent 012589c commit 2f487ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 2 additions & 4 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def self.fetch(name, fallback)

class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
# config.load_defaults 6.1
config.load_defaults 7.0

# Configuration for the application, engines, and railties goes here.
Expand All @@ -44,9 +43,6 @@ class Application < Rails::Application
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")


config.load_defaults '6.0'

config.encoding = 'utf-8'

config.assets.css_compressor = nil
Expand All @@ -55,6 +51,8 @@ class Application < Rails::Application

config.action_cable.disable_request_forgery_protection = true

config.active_storage.variant_processor = :mini_magick

# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
Expand Down
10 changes: 10 additions & 0 deletions config/initializers/rotator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# a bug introduced in rails 7
# read: https://github.com/hotwired/turbo-rails/issues/340

Rails.application.config.after_initialize do |app|
key_generator = ActiveSupport::KeyGenerator.new app.secret_key_base,
iterations: 1000,
hash_digest_class: OpenSSL::Digest::SHA1

app.message_verifier("ActiveStorage").rotate(key_generator.generate_key("ActiveStorage"))
end

0 comments on commit 2f487ac

Please sign in to comment.