Sha256: 0258a92369965e9cc35f4983d5cf5115481760f20cabe437b84e1d5769772b75

Contents?: true

Size: 1.24 KB

Versions: 6

Compression:

Stored size: 1.24 KB

Contents

require 'aws-sessionstore-dynamodb'

module ActionDispatch
  module Session
    # Uses the Dynamo DB Session Store implementation to create a class that
    # extends ActionDispatch::Session. Rails will create a :dynamodb_store
    # configuration for session_store from this class name.
    #
    # This class will use the Rails secret_key_base unless otherwise provided.
    #
    # Configuration can also be provided in YAML files from Rails config, either
    # in "config/session_store.yml" or "config/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 < Aws::SessionStore::DynamoDB::RackMiddleware
      def initialize(app, options = {})
        options[:config_file] ||= config_file if config_file.exist?
        options[:secret_key] ||= Rails.application.secret_key_base
        super
      end

      private

      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
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
aws-sdk-rails-3.6.1 lib/action_dispatch/session/dynamodb_store.rb
aws-sdk-rails-3.6.0 lib/action_dispatch/session/dynamodb_store.rb
aws-sdk-rails-3.5.0 lib/action_dispatch/session/dynamodb_store.rb
aws-sdk-rails-3.4.0 lib/action_dispatch/session/dynamodb_store.rb
aws-sdk-rails-3.3.0 lib/action_dispatch/session/dynamodb_store.rb
aws-sdk-rails-3.2.1 lib/action_dispatch/session/dynamodb_store.rb