Merge pull request #5819 from consuldemocracy/remove_code_to_upgrade_to_2.2
Remove tasks to upgrade to version 2.2
This commit is contained in:
@@ -165,7 +165,6 @@ Layout/LineLength:
|
|||||||
- "config/environments/staging.rb"
|
- "config/environments/staging.rb"
|
||||||
- "config/initializers/devise.rb"
|
- "config/initializers/devise.rb"
|
||||||
- "config/initializers/backtrace_silencers.rb"
|
- "config/initializers/backtrace_silencers.rb"
|
||||||
- "config/initializers/active_storage_message_and_cookie_rotator.rb"
|
|
||||||
- "db/migrate/*create_delayed_jobs.rb"
|
- "db/migrate/*create_delayed_jobs.rb"
|
||||||
- "db/migrate/*create_active_storage_variant_records.active_storage.rb"
|
- "db/migrate/*create_active_storage_variant_records.active_storage.rb"
|
||||||
- "app/models/budget/stats.rb"
|
- "app/models/budget/stats.rb"
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
# This code was copied from:
|
|
||||||
# https://github.com/hotwired/turbo-rails/blob/v1.4.0/UPGRADING.md#key-digest-changes-in-111
|
|
||||||
# Removing this code will make ActiveStorage image URLs generated with Rails 6.1
|
|
||||||
# or earlier inaccessible, causing images attached with CKEditor or linked from
|
|
||||||
# somewhere else not to be rendered.
|
|
||||||
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
|
|
||||||
|
|
||||||
# This code was copied from:
|
|
||||||
# https://guides.rubyonrails.org/v7.0/upgrading_ruby_on_rails.html#key-generator-digest-class-changing-to-use-sha256
|
|
||||||
# TODO: safe to remove after upgrading to Rails 7.1 or releasing a new
|
|
||||||
# version of Consul Democracy
|
|
||||||
Rails.application.config.after_initialize do
|
|
||||||
Rails.application.config.action_dispatch.cookies_rotations.tap do |cookies|
|
|
||||||
authenticated_encrypted_cookie_salt = Rails.application.config.action_dispatch.authenticated_encrypted_cookie_salt
|
|
||||||
signed_cookie_salt = Rails.application.config.action_dispatch.signed_cookie_salt
|
|
||||||
|
|
||||||
secret_key_base = Rails.application.secret_key_base
|
|
||||||
|
|
||||||
key_generator = ActiveSupport::KeyGenerator.new(
|
|
||||||
secret_key_base, iterations: 1000, hash_digest_class: OpenSSL::Digest::SHA1
|
|
||||||
)
|
|
||||||
key_len = ActiveSupport::MessageEncryptor.key_len
|
|
||||||
|
|
||||||
old_encrypted_secret = key_generator.generate_key(authenticated_encrypted_cookie_salt, key_len)
|
|
||||||
old_signed_secret = key_generator.generate_key(signed_cookie_salt)
|
|
||||||
|
|
||||||
cookies.rotate :encrypted, old_encrypted_secret
|
|
||||||
cookies.rotate :signed, old_signed_secret
|
|
||||||
end
|
|
||||||
end
|
|
||||||
12
config/initializers/active_storage_message_rotator.rb
Normal file
12
config/initializers/active_storage_message_rotator.rb
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# This code was copied from:
|
||||||
|
# https://github.com/hotwired/turbo-rails/blob/v1.4.0/UPGRADING.md#key-digest-changes-in-111
|
||||||
|
# Removing this code will make ActiveStorage image URLs generated with Rails 6.1
|
||||||
|
# or earlier inaccessible, causing images attached with CKEditor or linked from
|
||||||
|
# somewhere else not to be rendered.
|
||||||
|
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
|
||||||
@@ -3,12 +3,8 @@ namespace :consul do
|
|||||||
task execute_release_tasks: ["settings:rename_setting_keys",
|
task execute_release_tasks: ["settings:rename_setting_keys",
|
||||||
"settings:add_new_settings",
|
"settings:add_new_settings",
|
||||||
"cache:clear",
|
"cache:clear",
|
||||||
"execute_release_2.2.0_tasks"]
|
"execute_release_2.3.0_tasks"]
|
||||||
|
|
||||||
desc "Runs tasks needed to upgrade from 2.1.1 to 2.2.0"
|
desc "Runs tasks needed to upgrade from 2.2.2 to 2.3.0"
|
||||||
task "execute_release_2.2.0_tasks": [
|
task "execute_release_2.3.0_tasks": []
|
||||||
"db:mask_ips",
|
|
||||||
"polls:remove_duplicate_voters",
|
|
||||||
"polls:populate_option_id"
|
|
||||||
]
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,15 +4,4 @@ namespace :db do
|
|||||||
I18n.enforce_available_locales = false
|
I18n.enforce_available_locales = false
|
||||||
Tenant.switch(args[:tenant]) { load(Rails.root.join("db", "dev_seeds.rb")) }
|
Tenant.switch(args[:tenant]) { load(Rails.root.join("db", "dev_seeds.rb")) }
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Mask IPs collected with Ahoy"
|
|
||||||
task mask_ips: :environment do
|
|
||||||
ApplicationLogger.new.info "Masking tracked IPs collected with Ahoy"
|
|
||||||
|
|
||||||
Tenant.run_on_each do
|
|
||||||
Visit.find_each do |visit|
|
|
||||||
visit.update_column :ip, Ahoy.mask_ip(visit.ip)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
require "rails_helper"
|
|
||||||
|
|
||||||
describe "rake db:mask_ips" do
|
|
||||||
before { Rake::Task["db:mask_ips"].reenable }
|
|
||||||
|
|
||||||
it "mask IPs on all tenants" do
|
|
||||||
create(:visit, ip: "1.1.1.1")
|
|
||||||
create(:visit, ip: "1.1.1.2")
|
|
||||||
create(:visit, ip: "1.1.2.2")
|
|
||||||
|
|
||||||
create(:tenant, schema: "myhometown")
|
|
||||||
|
|
||||||
Tenant.switch("myhometown") do
|
|
||||||
create(:visit, ip: "1.1.1.1")
|
|
||||||
create(:visit, ip: "1.1.1.2")
|
|
||||||
create(:visit, ip: "1.1.3.3")
|
|
||||||
end
|
|
||||||
|
|
||||||
Rake.application.invoke_task("db:mask_ips")
|
|
||||||
|
|
||||||
expect(Visit.pluck(:ip)).to match_array %w[1.1.1.0 1.1.1.0 1.1.2.0]
|
|
||||||
|
|
||||||
Tenant.switch("myhometown") do
|
|
||||||
expect(Visit.pluck(:ip)).to match_array %w[1.1.1.0 1.1.1.0 1.1.3.0]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Reference in New Issue
Block a user