diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f062eab..b6ecf951 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: fail-fast: false matrix: ruby: [2.7, '3.0', 3.1, 3.2, 3.3, jruby-9.4] - rails: ['7.0', 7.1, 7.2, main] + rails: [7.1, 7.2, main] exclude: # Rails 7.2 dropped support for older rubygems diff --git a/.rubocop.yml b/.rubocop.yml index 93d50d25..b42a58d1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,7 +6,8 @@ AllCops: SuggestExtensions: false Exclude: - 'tasks/release/**/*' - - 'sample_app/**/*' + - 'sample-app/**/*' + - 'sample_app_old/**/*' - 'spec/dummy/**/*' - 'spec/fixtures/**/*' - 'spec/fixtures/**/*' diff --git a/CHANGELOG.md b/CHANGELOG.md index bba42b52..2f411002 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,14 @@ Unreleased Changes ------------------ -* Feature - Add session store config generation. +* 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`. + 4.1.0 (2024-09-27) ------------------ diff --git a/README.md b/README.md index cebc1b5e..ff41b826 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ to have or create an existing Amazon DynamoDB session table to use this feature. To enable this feature, add the following to your Gemfile: ```ruby -gem 'aws-sessionstore-dynamodb', '~> 2' +gem 'aws-sessionstore-dynamodb', '~> 3' ``` For more information about this feature and configuration options, see the diff --git a/aws-sdk-rails.gemspec b/aws-sdk-rails.gemspec index 46ccd554..67f5e465 100644 --- a/aws-sdk-rails.gemspec +++ b/aws-sdk-rails.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |spec| spec.executables = ['aws_sqs_active_job'] spec.add_dependency('aws-record', '~> 2') # for Aws::Record integration - spec.add_dependency('aws-sessionstore-dynamodb', '~> 2') # includes DynamoDB + spec.add_dependency('aws-sessionstore-dynamodb', '~> 3') # includes DynamoDB # Require these versions for user_agent_framework configs spec.add_dependency('aws-sdk-s3', '~> 1', '>= 1.123.0') diff --git a/gemfiles/rails-7.0.gemfile b/gemfiles/rails-7.0.gemfile deleted file mode 100644 index a0f83409..00000000 --- a/gemfiles/rails-7.0.gemfile +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -eval_gemfile '../Gemfile' - -gem 'rails', '~> 7.0.0' - -group :test do - # JDBC versions track Rails versions - gem 'activerecord-jdbcsqlite3-adapter', '~> 70.0', platform: :jruby - # last supported version of sqlite3 for minimum ruby - gem 'sqlite3', '~> 1.6.0', platform: :ruby -end diff --git a/lib/action_dispatch/session/dynamo_db_store.rb b/lib/action_dispatch/session/dynamo_db_store.rb index 5f0f6a89..271852bf 100644 --- a/lib/action_dispatch/session/dynamo_db_store.rb +++ b/lib/action_dispatch/session/dynamo_db_store.rb @@ -16,28 +16,39 @@ module Session # 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 < Aws::SessionStore::DynamoDB::RackMiddleware - # Because of how Ruby searches for methods in the inheritance chain, - # generate_sid in Compatibility takes precedence over our generate_sid. - # Compatibility is needed so that the request is an ActionDispatch::Request. - CompatibilityWithoutSid = Compatibility.dup - CompatibilityWithoutSid.remove_method(:generate_sid) - include CompatibilityWithoutSid - - include StaleSessionCheck - include SessionObject - + 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 ~> 2 to your Gemfile to enable ' \ + '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 = 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)