From b38e4e281695e31cf20fa0ca0d7883e65dd1dc29 Mon Sep 17 00:00:00 2001 From: Matt Muller Date: Tue, 12 Nov 2024 16:36:55 -0500 Subject: [PATCH 1/5] Relocate ActionDispatch DynamoDB --- Gemfile | 2 + aws-sdk-rails.gemspec | 2 +- .../session/dynamo_db_store.rb | 70 ------------------ lib/aws-sdk-rails.rb | 4 +- lib/aws/rails/railtie.rb | 2 +- .../dynamo_db/session_store_config/USAGE | 16 ----- .../session_store_config_generator.rb | 24 ------- .../templates/dynamo_db_session_store.yml | 70 ------------------ .../dynamo_db/session_store_migration/USAGE | 17 ----- .../session_store_migration_generator.rb | 39 ---------- .../templates/session_store_migration.erb | 13 ---- lib/tasks/dynamo_db/session_store.rake | 23 ------ .../session/dynamo_db_store_test.rb | 71 ------------------- .../dynamo_db_session_store/development.yml | 70 ------------------ .../session_store_config_generator_test.rb | 27 ------- .../session_store_migration_generator_test.rb | 27 ------- .../dynamo_db/session_store_rake_test.rb | 52 -------------- 17 files changed, 5 insertions(+), 524 deletions(-) delete mode 100644 lib/action_dispatch/session/dynamo_db_store.rb delete mode 100644 lib/generators/dynamo_db/session_store_config/USAGE delete mode 100644 lib/generators/dynamo_db/session_store_config/session_store_config_generator.rb delete mode 100644 lib/generators/dynamo_db/session_store_config/templates/dynamo_db_session_store.yml delete mode 100644 lib/generators/dynamo_db/session_store_migration/USAGE delete mode 100644 lib/generators/dynamo_db/session_store_migration/session_store_migration_generator.rb delete mode 100644 lib/generators/dynamo_db/session_store_migration/templates/session_store_migration.erb delete mode 100644 lib/tasks/dynamo_db/session_store.rake delete mode 100644 test/action_dispatch/session/dynamo_db_store_test.rb delete mode 100644 test/dummy/config/dynamo_db_session_store/development.yml delete mode 100644 test/generators/dynamo_db/session_store_config/session_store_config_generator_test.rb delete mode 100644 test/generators/dynamo_db/session_store_migration/session_store_migration_generator_test.rb delete mode 100644 test/tasks/dynamo_db/session_store_rake_test.rb diff --git a/Gemfile b/Gemfile index 7d2b5aeb..1e07ebcb 100644 --- a/Gemfile +++ b/Gemfile @@ -4,6 +4,8 @@ source 'https://rubygems.org' gemspec +gem 'aws-actiondispatch-dynamodb', git: 'https://github.com/aws/aws-actiondispatch-dynamodb-ruby', branch: 'init' + group :development, :test do gem 'pry' end diff --git a/aws-sdk-rails.gemspec b/aws-sdk-rails.gemspec index b1410ec5..7d6d33c4 100644 --- a/aws-sdk-rails.gemspec +++ b/aws-sdk-rails.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |spec| # These will be removed in aws-sdk-rails ~> 5 spec.add_dependency('aws-record', '~> 2') # for Aws::Record integration - spec.add_dependency('aws-sessionstore-dynamodb', '~> 3') # includes DynamoDB + spec.add_dependency('aws-actiondispatch-dynamodb', '~> 0') # Require these versions for user_agent_framework configs spec.add_dependency('aws-sdk-s3', '~> 1', '>= 1.123.0') diff --git a/lib/action_dispatch/session/dynamo_db_store.rb b/lib/action_dispatch/session/dynamo_db_store.rb deleted file mode 100644 index bfc02943..00000000 --- a/lib/action_dispatch/session/dynamo_db_store.rb +++ /dev/null @@ -1,70 +0,0 @@ -# frozen_string_literal: true - -require 'action_dispatch/middleware/session/abstract_store' - -module ActionDispatch - module Session - # Uses the Dynamo DB Session Store implementation to create a class that - # extends `ActionDispatch::Session`. Rails will create a `:dynamo_db_store` - # configuration for `:session_store` from this class name. - # - # This class will use `Rails.application.secret_key_base` as the secret key - # unless otherwise provided. - # - # Configuration can also be provided in YAML files from Rails config, either - # in "config/dynamo_db_session_store.yml" or "config/dynamo_db_session_store/#\\{Rails.env}.yml". - # Configuration files that are environment-specific will take precedence. - # - # @see https://docs.aws.amazon.com/sdk-for-ruby/aws-sessionstore-dynamodb/api/Aws/SessionStore/DynamoDB/Configuration.html - class DynamoDbStore < ActionDispatch::Session::AbstractStore - def initialize(app, options = {}) - Rails.logger.warn('** aws-sessionstore-dynamodb will no longer be a direct dependency of aws-sdk-rails ~> 5. ' \ - 'To avoid disruption, please add aws-sessionstore-dynamodb ~> 3 to your Gemfile to enable ' \ - 'this feature when upgrading to aws-sdk-rails ~> 5. **') - options[:config_file] ||= config_file - options[:secret_key] ||= Rails.application.secret_key_base - @middleware = Aws::SessionStore::DynamoDB::RackMiddleware.new(app, options) - super - end - - # @return [Aws::SessionStore::DynamoDB::Configuration] - def config - @middleware.config - end - - private - - # Required by `ActionDispatch::Session::AbstractStore` - def find_session(req, sid) - @middleware.find_session(req, sid) - end - - # Required by `ActionDispatch::Session::AbstractStore` - def write_session(req, sid, session, options) - @middleware.write_session(req, sid, session, options) - end - - # Required by `ActionDispatch::Session::AbstractStore` - def delete_session(req, sid, options) - @middleware.delete_session(req, sid, options) - end - - def config_file - file = ENV.fetch('DYNAMO_DB_SESSION_CONFIG_FILE', nil) - file ||= Rails.root.join("config/dynamo_db_session_store/#{Rails.env}.yml") - file = Rails.root.join('config/dynamo_db_session_store.yml') unless File.exist?(file) - file if File.exist?(file) - end - end - - # @api private - class DynamodbStore < DynamoDbStore - def initialize(app, options = {}) - Rails.logger.warn('** Session Store :dynamodb_store configuration key has been renamed to :dynamo_db_store, ' \ - 'please use the new key instead. The :dynamodb_store key name will be removed in ' \ - 'aws-sdk-rails ~> 5 **') - super - end - end - end -end diff --git a/lib/aws-sdk-rails.rb b/lib/aws-sdk-rails.rb index 50969feb..01818bef 100644 --- a/lib/aws-sdk-rails.rb +++ b/lib/aws-sdk-rails.rb @@ -9,9 +9,7 @@ require_relative 'aws/rails/middleware/ebs_sqs_active_job_middleware' # remove this in aws-sdk-rails 5 -require 'aws-sessionstore-dynamodb' - -require_relative 'action_dispatch/session/dynamo_db_store' if defined?(Aws::SessionStore::DynamoDB::RackMiddleware) +require 'aws-actiondispatch-dynamodb' module Aws module Rails diff --git a/lib/aws/rails/railtie.rb b/lib/aws/rails/railtie.rb index b20b18c2..7076f870 100644 --- a/lib/aws/rails/railtie.rb +++ b/lib/aws/rails/railtie.rb @@ -36,7 +36,7 @@ class Railtie < ::Rails::Railtie end rake_tasks do - load 'tasks/dynamo_db/session_store.rake' if defined?(Aws::SessionStore::DynamoDB) + load 'tasks/dynamo_db/session_store.rake' if defined?(Aws::ActionDispatch::DynamoDb) load 'tasks/aws_record/migrate.rake' if defined?(Aws::Record) end end diff --git a/lib/generators/dynamo_db/session_store_config/USAGE b/lib/generators/dynamo_db/session_store_config/USAGE deleted file mode 100644 index 35cb2585..00000000 --- a/lib/generators/dynamo_db/session_store_config/USAGE +++ /dev/null @@ -1,16 +0,0 @@ -Description: - Generates a sample configuration file DynamoDB session store. - -Examples: - `rails generate dynamo_db:session_store_config` - - This will create: - config/dynamo_db_session_store.yml - - Optionally, you can specify the Rails environment to generate - the configuration file for: - - `rails generate dynamo_db:session_store_config --environment=development` - - This will create: - config/dynamo_db_session_store/development.yml diff --git a/lib/generators/dynamo_db/session_store_config/session_store_config_generator.rb b/lib/generators/dynamo_db/session_store_config/session_store_config_generator.rb deleted file mode 100644 index 89075b7e..00000000 --- a/lib/generators/dynamo_db/session_store_config/session_store_config_generator.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -require 'rails/generators' - -module DynamoDb - module Generators - # Generates a config file for DynamoDB session storage. - class SessionStoreConfigGenerator < Rails::Generators::Base - source_root File.expand_path('templates', __dir__) - - # Environment to generate the config file for - class_option :environment, - desc: 'Optional rails environment to generate the config file for', - type: :string, - default: nil - - def copy_sample_config_file - path = 'config/dynamo_db_session_store' - path += "/#{options['environment']}" if options['environment'] - template('dynamo_db_session_store.yml', "#{path}.yml") - end - end - end -end diff --git a/lib/generators/dynamo_db/session_store_config/templates/dynamo_db_session_store.yml b/lib/generators/dynamo_db/session_store_config/templates/dynamo_db_session_store.yml deleted file mode 100644 index c5c5b6fb..00000000 --- a/lib/generators/dynamo_db/session_store_config/templates/dynamo_db_session_store.yml +++ /dev/null @@ -1,70 +0,0 @@ -# Uncomment and manipulate the key value pairs below -# in order to configure the DynamoDB Session Store Application. - -# [String] Session table name. -# -# table_name: Sessions - -# [String] Session table hash key name. -# -# table_key: session_id - -# [String] The secret key for HMAC encryption. This defaults to -# `Rails.application.secret_key_base`. You can use a different key if desired. -# -# secret_key: SECRET_KEY - -# [Boolean] Define as true or false depending on if you want a strongly -# consistent read. -# See AWS DynamoDB documentation for table consistent_read for more -# information on this setting. -# -# consistent_read: true - -# [Integer] Maximum number of reads consumed per second before -# DynamoDB returns a ThrottlingException. See AWS DynamoDB documentation -# or table read_capacity for more information on this setting. -# -# read_capacity: 10 - -# [Integer] Maximum number of writes consumed per second before -# DynamoDB returns a ThrottlingException. See AWS DynamoDB documentation -# or table write_capacity for more information on this setting. -# -# write_capacity: 5 - -# [Boolean] Define as true or false depending on whether you want all errors to be -# raised up the stack. -# -# raise_errors: false - -# [Integer] Maximum number of seconds earlier -# from the current time that a session was created. -# By default this is 7 days. -# -# max_age: 604800 - -# [Integer] Maximum number of seconds -# before the current time that the session was last accessed. -# By default this is 5 hours. -# -# max_stale: 18000 - -# [Boolean] Define as true or false for whether you want to enable locking -# for all accesses to session data. -# -# enable_locking: false - -# [Integer] Time in milleseconds after which lock will expire. -# -# lock_expiry_time: 500 - -# [Integer] Time in milleseconds to wait before retrying to obtain -# lock once an attempt to obtain lock has been made and has failed. -# -# lock_retry_delay: 500 - -# [Integer] Maximum time in seconds to wait to acquire lock -# before giving up. -# -# lock_max_wait_time: 1 diff --git a/lib/generators/dynamo_db/session_store_migration/USAGE b/lib/generators/dynamo_db/session_store_migration/USAGE deleted file mode 100644 index fc06f33e..00000000 --- a/lib/generators/dynamo_db/session_store_migration/USAGE +++ /dev/null @@ -1,17 +0,0 @@ -Description: - Generates an ActiveRecord migration for deleting and a creating - a DynamoDB sessions table. The migration will be run when the - command `rake db:migrate` is run in the command line. - -Example: - `rails generate dynamo_db:session_store_migration` - - This will create: - db/migrate/#{VERSION}_create_dynamo_db_sessions_table.rb - - Optionally, you can specify the name of the migration: - - `rails generate dynamo_db:session_store_migration MIGRATION_NAME` - - This will create: - db/migrate/#{VERSION}_.rb diff --git a/lib/generators/dynamo_db/session_store_migration/session_store_migration_generator.rb b/lib/generators/dynamo_db/session_store_migration/session_store_migration_generator.rb deleted file mode 100644 index 8cc74ed5..00000000 --- a/lib/generators/dynamo_db/session_store_migration/session_store_migration_generator.rb +++ /dev/null @@ -1,39 +0,0 @@ -# frozen_string_literal: true - -require 'rails/generators' - -module DynamoDb - module Generators - # Generates an ActiveRecord migration that creates and deletes a DynamoDB - # Session table. - class SessionStoreMigrationGenerator < Rails::Generators::NamedBase - include Rails::Generators::Migration - - source_root File.expand_path('templates', __dir__) - - # Desired name of the migration class - argument :name, - desc: 'Optional name of the migration class', - type: :string, - default: 'create_dynamo_db_sessions_table' - - def generate_migration_file - migration_template( - 'session_store_migration.erb', - "db/migrate/#{name.underscore}.rb" - ) - end - - # Next migration number - must be implemented - def self.next_migration_number(_dir = nil) - Time.now.utc.strftime('%Y%m%d%H%M%S') - end - - private - - def migration_version - "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}" - end - end - end -end diff --git a/lib/generators/dynamo_db/session_store_migration/templates/session_store_migration.erb b/lib/generators/dynamo_db/session_store_migration/templates/session_store_migration.erb deleted file mode 100644 index 3959f135..00000000 --- a/lib/generators/dynamo_db/session_store_migration/templates/session_store_migration.erb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class <%= name.camelize %> < ActiveRecord::Migration[<%= migration_version %>] - def up - options = Rails.application.config.session_options - Aws::SessionStore::DynamoDB::Table.create_table(options) - end - - def down - options = Rails.application.config.session_options - Aws::SessionStore::DynamoDB::Table.delete_table(options) - end -end diff --git a/lib/tasks/dynamo_db/session_store.rake b/lib/tasks/dynamo_db/session_store.rake deleted file mode 100644 index ec22055c..00000000 --- a/lib/tasks/dynamo_db/session_store.rake +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -namespace 'dynamo_db' do - namespace 'session_store' do - desc 'Create the Amazon DynamoDB session store table' - task create_table: :environment do - options = Rails.application.config.session_options - Aws::SessionStore::DynamoDB::Table.create_table(options) - end - - desc 'Delete the Amazon DynamoDB session store table' - task delete_table: :environment do - options = Rails.application.config.session_options - Aws::SessionStore::DynamoDB::Table.delete_table(options) - end - - desc 'Clean up old sessions in the Amazon DynamoDB session store table' - task clean: :environment do - options = Rails.application.config.session_options - Aws::SessionStore::DynamoDB::GarbageCollection.collect_garbage(options) - end - end -end diff --git a/test/action_dispatch/session/dynamo_db_store_test.rb b/test/action_dispatch/session/dynamo_db_store_test.rb deleted file mode 100644 index 0f1f89f6..00000000 --- a/test/action_dispatch/session/dynamo_db_store_test.rb +++ /dev/null @@ -1,71 +0,0 @@ -# frozen_string_literal: true - -require 'test_helper' - -require 'aws-sdk-dynamodb' - -module ActionDispatch - module Session - class DynamoDbStoreTest < ActiveSupport::TestCase - let(:options) do - { dynamo_db_client: Aws::DynamoDB::Client.new(stub_responses: true) } - end - - def setup_env - ENV['DYNAMO_DB_SESSION_CONFIG_FILE'] = 'test/dummy/config/session_store.yml' - end - - def teardown_env - ENV.delete('DYNAMO_DB_SESSION_CONFIG_FILE') - end - - it 'loads config file' do - store = ActionDispatch::Session::DynamoDbStore.new(nil, options) - config_file_path = store.config.config_file.to_s - assert_match(/dynamo_db_session_store.yml/, config_file_path) - end - - it 'loads environment specific config files with precedence' do - # Set Rails.env to something else so the environment.yml file is loaded - old_env = Rails.env - Rails.env = 'development' - - store = ActionDispatch::Session::DynamoDbStore.new(nil, options) - config_file_path = store.config.config_file.to_s - assert_match(/development.yml/, config_file_path) - - # Reload old env - Rails.env = old_env - end - - it 'loads a config file from the environment variable with precedence' do - setup_env - store = ActionDispatch::Session::DynamoDbStore.new(nil, options) - config_file_path = store.config.config_file.to_s - assert_match(/session_store.yml/, config_file_path) - teardown_env - end - - it 'allows overriding the config file at runtime with highest precedence' do - setup_env - options[:config_file] = 'test/dummy/config/session_store.yml' - store = ActionDispatch::Session::DynamoDbStore.new(nil, options) - config_file_path = store.config.config_file.to_s - assert_match(/session_store.yml/, config_file_path) - teardown_env - end - - it 'uses the rails secret key base' do - store = ActionDispatch::Session::DynamoDbStore.new(nil, options) - assert_equal store.config.secret_key, Rails.application.secret_key_base - end - - it 'allows for secret key to be overridden' do - secret_key = 'SECRET_KEY' - options[:secret_key] = secret_key - store = ActionDispatch::Session::DynamoDbStore.new(nil, options) - assert_equal store.config.secret_key, secret_key - end - end - end -end diff --git a/test/dummy/config/dynamo_db_session_store/development.yml b/test/dummy/config/dynamo_db_session_store/development.yml deleted file mode 100644 index c5c5b6fb..00000000 --- a/test/dummy/config/dynamo_db_session_store/development.yml +++ /dev/null @@ -1,70 +0,0 @@ -# Uncomment and manipulate the key value pairs below -# in order to configure the DynamoDB Session Store Application. - -# [String] Session table name. -# -# table_name: Sessions - -# [String] Session table hash key name. -# -# table_key: session_id - -# [String] The secret key for HMAC encryption. This defaults to -# `Rails.application.secret_key_base`. You can use a different key if desired. -# -# secret_key: SECRET_KEY - -# [Boolean] Define as true or false depending on if you want a strongly -# consistent read. -# See AWS DynamoDB documentation for table consistent_read for more -# information on this setting. -# -# consistent_read: true - -# [Integer] Maximum number of reads consumed per second before -# DynamoDB returns a ThrottlingException. See AWS DynamoDB documentation -# or table read_capacity for more information on this setting. -# -# read_capacity: 10 - -# [Integer] Maximum number of writes consumed per second before -# DynamoDB returns a ThrottlingException. See AWS DynamoDB documentation -# or table write_capacity for more information on this setting. -# -# write_capacity: 5 - -# [Boolean] Define as true or false depending on whether you want all errors to be -# raised up the stack. -# -# raise_errors: false - -# [Integer] Maximum number of seconds earlier -# from the current time that a session was created. -# By default this is 7 days. -# -# max_age: 604800 - -# [Integer] Maximum number of seconds -# before the current time that the session was last accessed. -# By default this is 5 hours. -# -# max_stale: 18000 - -# [Boolean] Define as true or false for whether you want to enable locking -# for all accesses to session data. -# -# enable_locking: false - -# [Integer] Time in milleseconds after which lock will expire. -# -# lock_expiry_time: 500 - -# [Integer] Time in milleseconds to wait before retrying to obtain -# lock once an attempt to obtain lock has been made and has failed. -# -# lock_retry_delay: 500 - -# [Integer] Maximum time in seconds to wait to acquire lock -# before giving up. -# -# lock_max_wait_time: 1 diff --git a/test/generators/dynamo_db/session_store_config/session_store_config_generator_test.rb b/test/generators/dynamo_db/session_store_config/session_store_config_generator_test.rb deleted file mode 100644 index d36a7b9e..00000000 --- a/test/generators/dynamo_db/session_store_config/session_store_config_generator_test.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -require 'test_helper' - -require 'fileutils' -require 'generators/dynamo_db/session_store_config/session_store_config_generator' - -module DynamoDb - module Generators - class SessionStoreConfigGeneratorTest < Rails::Generators::TestCase - tests SessionStoreConfigGenerator - destination File.expand_path('../../../dummy', __dir__) - - it 'generates config file' do - FileUtils.rm_rf(Dir["#{destination_root}/config/dynamo_db_session_store.yml"]) - run_generator - assert_file 'config/dynamo_db_session_store.yml' - end - - it 'generates config file with environment' do - FileUtils.rm_rf(Dir["#{destination_root}/config/dynamo_db_session_store/development.yml"]) - run_generator %w[--environment=development] - assert_file 'config/dynamo_db_session_store/development.yml' - end - end - end -end diff --git a/test/generators/dynamo_db/session_store_migration/session_store_migration_generator_test.rb b/test/generators/dynamo_db/session_store_migration/session_store_migration_generator_test.rb deleted file mode 100644 index e4c9c05e..00000000 --- a/test/generators/dynamo_db/session_store_migration/session_store_migration_generator_test.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -require 'test_helper' - -require 'fileutils' -require 'generators/dynamo_db/session_store_migration/session_store_migration_generator' - -module DynamoDb - module Generators - class SessionStoreMigrationGeneratorTest < Rails::Generators::TestCase - tests SessionStoreMigrationGenerator - destination File.expand_path('../../../dummy', __dir__) - - it 'generates migration' do - FileUtils.rm_rf(Dir["#{destination_root}/db/migrate/*create_dynamo_db_sessions_table.rb"]) - run_generator - assert_migration 'db/migrate/create_dynamo_db_sessions_table.rb' - end - - it 'generates migration with custom name' do - FileUtils.rm_rf(Dir["#{destination_root}/db/migrate/*custom_name.rb"]) - run_generator %w[CustomName] - assert_migration 'db/migrate/custom_name.rb' - end - end - end -end diff --git a/test/tasks/dynamo_db/session_store_rake_test.rb b/test/tasks/dynamo_db/session_store_rake_test.rb deleted file mode 100644 index c6051de5..00000000 --- a/test/tasks/dynamo_db/session_store_rake_test.rb +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -require 'test_helper' - -require 'rake' - -module DynamoDb - class SessionStoreRakeTest < ActiveSupport::TestCase - before do - Rake.application.rake_require 'tasks/dynamo_db/session_store' - Rake::Task.define_task(:environment) - # MiniTest has an issue with kwargs in 2.7 - # https://github.com/minitest/minitest/blob/master/lib/minitest/mock.rb#L293C8-L293C30 - ENV["MT_KWARGS_HAC\K"] = '1' if RUBY_VERSION < '3' - end - - after do - ENV.delete("MT_KWARGS_HAC\K") - end - - # Functionality for these methods are tested in aws-sessionstore-dynamodb. - # For these tests, just validate the task can be invoked and calls the - # appropriate methods. - def expect_mock(method, task) - klass = - if method == :collect_garbage - Aws::SessionStore::DynamoDB::GarbageCollection - else - Aws::SessionStore::DynamoDB::Table - end - - mock = MiniTest::Mock.new - # After removing ENV["MT_KWARGS_HAC\K"], this can be stronger by asserting - # Rails.application.config.session_options is passed to the method. - mock.expect(:call, nil, [Hash]) - klass.stub(method, mock) { Rake.application.invoke_task task } - assert_mock mock - end - - it 'has a creates table task' do - expect_mock(:create_table, 'dynamo_db:session_store:create_table') - end - - it 'has a deletes table task' do - expect_mock(:delete_table, 'dynamo_db:session_store:delete_table') - end - - it 'has a collect garbage task' do - expect_mock(:collect_garbage, 'dynamo_db:session_store:clean') - end - end -end From 9f00729fd255d2d57f4a8a6d3885957b28cc99cc Mon Sep 17 00:00:00 2001 From: Matt Muller Date: Wed, 13 Nov 2024 09:06:35 -0500 Subject: [PATCH 2/5] Update gemfile --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 14d8b3c0..3169ba2e 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ source 'https://rubygems.org' gemspec -gem 'aws-actiondispatch-dynamodb', git: 'https://github.com/aws/aws-actiondispatch-dynamodb-ruby', branch: 'init' +gem 'aws-actiondispatch-dynamodb', git: 'https://github.com/aws/aws-actiondispatch-dynamodb-ruby' gem 'aws-actionmailer-ses', git: 'https://github.com/aws/aws-actionmailer-ses-ruby' group :development, :test do From e14bf541735a0dcd6d7b2005011e300c367f9195 Mon Sep 17 00:00:00 2001 From: Matt Muller Date: Wed, 13 Nov 2024 09:09:08 -0500 Subject: [PATCH 3/5] Update testing README --- sample-app/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample-app/README.md b/sample-app/README.md index d0db864a..c7ab89b1 100644 --- a/sample-app/README.md +++ b/sample-app/README.md @@ -73,7 +73,7 @@ Got notification: update_item.DynamoDB.aws ... ### Setup -This is configured in `config/initializers/session_store.rb`. See [this guide](https://guides.rubyonrails.org/v3.1/configuring.html#rails-general-configuration) and the `aws-sdk-rails` README. +This is configured in `config/initializers/session_store.rb`. See [this guide](https://guides.rubyonrails.org/configuring.html#config-session-store) and the `aws-sdk-rails` README. The default configuration file was generated with `bundle exec rails generate dynamo_db:session_store_config`. From ea2fd34b8118583342b09032131f5c7c9f0735d6 Mon Sep 17 00:00:00 2001 From: Matt Muller Date: Wed, 13 Nov 2024 09:10:43 -0500 Subject: [PATCH 4/5] Fix rubocop and tests --- aws-sdk-rails.gemspec | 2 +- lib/aws/rails/middleware/ebs_sqs_active_job_middleware.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/aws-sdk-rails.gemspec b/aws-sdk-rails.gemspec index d78b3630..589732fc 100644 --- a/aws-sdk-rails.gemspec +++ b/aws-sdk-rails.gemspec @@ -15,9 +15,9 @@ Gem::Specification.new do |spec| spec.executables = ['aws_sqs_active_job'] # These will be removed in aws-sdk-rails ~> 5 + spec.add_dependency('aws-actiondispatch-dynamodb', '~> 0') spec.add_dependency('aws-actionmailer-ses', '~> 0') spec.add_dependency('aws-record', '~> 2') # for Aws::Record integration - spec.add_dependency('aws-actiondispatch-dynamodb', '~> 0') # Require these versions for user_agent_framework configs spec.add_dependency('aws-sdk-s3', '~> 1', '>= 1.123.0') diff --git a/lib/aws/rails/middleware/ebs_sqs_active_job_middleware.rb b/lib/aws/rails/middleware/ebs_sqs_active_job_middleware.rb index f5394046..296ec58b 100644 --- a/lib/aws/rails/middleware/ebs_sqs_active_job_middleware.rb +++ b/lib/aws/rails/middleware/ebs_sqs_active_job_middleware.rb @@ -15,7 +15,7 @@ def initialize(app) end def call(env) - request = ActionDispatch::Request.new(env) + request = ::ActionDispatch::Request.new(env) # Pass through unless user agent is the SQS Daemon return @app.call(env) unless from_sqs_daemon?(request) From 79ab50c3fbe0d3ace2da5e27f0fa95388c028242 Mon Sep 17 00:00:00 2001 From: Matt Muller Date: Wed, 13 Nov 2024 09:18:46 -0500 Subject: [PATCH 5/5] Improve CHANGELOG --- CHANGELOG.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fef55a14..41f309c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,27 +1,27 @@ Unreleased Changes ------------------ -* Feature - Prepare modularization of `aws-record`. +* Feature - DynamoDB Session Storage features now live in the `aws-actiondispatch-dynamodb` gem. This gem depends on `aws-sessionstore-dynamodb ~> 3` which depends on `rack ~> 3` and is not supported by Rails `7.0`. * Feature - Add session store config generation with `rails generate dynamo_db:session_store_config`. Config generation is no longer tied to the DynamoDB SessionStore ActiveRecord migration generator. -* Feature - Prepare modularization of `aws-sessionstore-dynamodb`. - -* Feature - Depend on `aws-sessionstore-dynamodb ~> 3` which depends on `rack ~> 3` and is not supported by Rails `7.0`. - * Issue - `ActionDispatch::Session::DynamoDbStore` now inherits `ActionDispatch::Session::AbstractStore` by wrapping `Aws::SessionStore::DynamoDB::RackMiddleware`. * Issue - `DynamoDbStore` is now configured with the `:dynamo_db_store` configuration instead of `:dynamodb_store`. -* Feature - `DYNAMO_DB_SESSION_CONFIG_FILE` is now searched and with precedence over the default Rails configuration YAML file locations. +* Feature - Session Store configuration passed into `:dynamo_db_store` in an initializer will now be considered when using the ActiveRecord migrations or rake tasks that create, delete, or clean session tables. -* Feature - Session Store configuration passed into `:dynamo_db_store` will now be considered when using the ActiveRecord migrations or rake tasks that create, delete, or clean session tables. +* Feature - `AWS_DYNAMO_DB_SESSION_CONFIG_FILE` is now searched and with precedence over the default Rails configuration YAML file locations. + +* Feature - Prepare modularization of `aws-record`. * Issue - Do not skip autoload modules for `Aws::Rails.instrument_sdk_operations`. -* Issue - Add deprecation warning to `Aws::Rails.add_action_mailer_delivery_method` to instead use `ActionMailer::Base.add_delivery_method`. +* Feature - ActionMailer SES and SESV2 mailers now live in the `aws-actionmailer-ses` gem. + +* Feature - New namespace and class names for SES and SESV2 mailers. `Aws::Rails::SesMailer` has been moved to `Aws::ActionMailer::SES::Mailer` and `Aws::Rails::Sesv2Mailer` has been moved to `Aws::ActionMailer::SESV2::Mailer`. The classes have been symlinked for backwards compatibility in this major version. -* Feature - New namespace and class names for SES and SESV2 mailers. Existing namespace has temporarily been kept for backward compatibility. These now live in the `aws-actionmailer-ses` gem. +* Issue - Add deprecation warning to `Aws::Rails.add_action_mailer_delivery_method` to instead use `ActionMailer::Base.add_delivery_method`. This method will be removed in the next major version. 4.1.0 (2024-09-27) ------------------