aws-sdk-rails 3.1.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of aws-sdk-rails might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c6f3ca6246615704132c2a690056d8c8636fd40947f756e79318affd6148720
4
- data.tar.gz: e17f171dba5c857c58358a6e35d962b398ada43439c78c8e0df496ed342dd1ef
3
+ metadata.gz: 68ff55530ced9007dd1eaa522efe123f6d809a5201d276d373d11171d1904e5b
4
+ data.tar.gz: 9f632d07b8eae350793893c4b002b0521ea81344c1ca2c0d06ad4a233281635d
5
5
  SHA512:
6
- metadata.gz: 61effb18895b3c4de7aa1cb8e44de99f5c497ac0ff996e5d74ae99af1b363dc634bb753e2c2160d437ede22988cdcb145b6683989864ee42b4cc029487649a0c
7
- data.tar.gz: 3b7ebe7488bd432776e1c594dc0325b7d75a964276d7e5af1ab05bbb66f3139de581ccc8c77730d97d69b8b39d5ab0312cb9e5f1fb719b9c5da5f0ce9dde1c5b
6
+ metadata.gz: 0ed6d161835182d189efbf4a454b26e4130ba6b761c518de488f780550c345fdce91b7a5381553a4625562f85d335a102ecb90ac4d027114d97aa14375680295
7
+ data.tar.gz: 013621f75c07d1c2cabf2b88a66882f39fb08803427c5cc44444eeb01378c76177ab47f13cb05349a876540cf13aea568ae800848b2cd02a14bcbe3cb6baf4ca
@@ -0,0 +1,32 @@
1
+ require 'aws-sessionstore-dynamodb'
2
+
3
+ module ActionDispatch
4
+ module Session
5
+ # Uses the Dynamo DB Session Store implementation to create a class that
6
+ # extends ActionDispatch::Session. Rails will create a :dynamodb_store
7
+ # configuration for session_store from this class name.
8
+ #
9
+ # This class will use the Rails secret_key_base unless otherwise provided.
10
+ #
11
+ # Configuration can also be provided in YAML files from Rails config, either
12
+ # in "config/session_store.yml" or "config/session_store/#{Rails.env}.yml".
13
+ # Configuration files that are environment-specific will take precedence.
14
+ #
15
+ # @see https://docs.aws.amazon.com/sdk-for-ruby/aws-sessionstore-dynamodb/api/Aws/SessionStore/DynamoDB/Configuration.html
16
+ class DynamodbStore < Aws::SessionStore::DynamoDB::RackMiddleware
17
+ def initialize(app, options = {})
18
+ options[:config_file] ||= config_file if config_file.exist?
19
+ options[:secret_key] ||= Rails.application.secret_key_base
20
+ super
21
+ end
22
+
23
+ private
24
+
25
+ def config_file
26
+ file = Rails.root.join("config/dynamo_db_session_store/#{Rails.env}.yml")
27
+ file = Rails.root.join('config/dynamo_db_session_store.yml') unless file.exist?
28
+ file
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,51 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'aws/rails/mailer'
4
+ require_relative 'aws/rails/railtie'
5
+ require_relative 'aws/rails/notifications'
4
6
 
5
- module Aws
6
- # Use the Rails namespace.
7
- module Rails
8
- # @api private
9
- class Railtie < ::Rails::Railtie
10
- initializer 'aws-sdk-rails.initialize',
11
- before: :load_config_initializers do
12
- # Initialization Actions
13
- Aws::Rails.use_rails_encrypted_credentials
14
- Aws::Rails.add_action_mailer_delivery_method
15
- Aws::Rails.log_to_rails_logger
16
- end
17
- end
18
-
19
- # This is called automatically from the SDK's Railtie, but can be manually
20
- # called if you want to specify options for building the Aws::SES::Client.
21
- #
22
- # @param [Symbol] name The name of the ActionMailer delivery method to
23
- # register.
24
- # @param [Hash] options The options you wish to pass on to the
25
- # Aws::SES::Client initialization method.
26
- def self.add_action_mailer_delivery_method(name = :ses, options = {})
27
- ActiveSupport.on_load(:action_mailer) do
28
- add_delivery_method(name, Aws::Rails::Mailer, options)
29
- end
30
- end
31
-
32
- # Configures the AWS SDK for Ruby's logger to use the Rails logger.
33
- def self.log_to_rails_logger
34
- Aws.config[:logger] = ::Rails.logger
35
- nil
36
- end
37
-
38
- # Configures the AWS SDK with credentials from Rails encrypted credentials.
39
- def self.use_rails_encrypted_credentials
40
- # limit the config keys we merge to credentials only
41
- aws_credential_keys = %i[access_key_id secret_access_key session_token]
42
-
43
- Aws.config.merge!(
44
- ::Rails.application
45
- .try(:credentials)
46
- .try(:aws)
47
- .to_h.slice(*aws_credential_keys)
48
- )
49
- end
50
- end
51
- end
7
+ require_relative 'action_dispatch/session/dynamodb_store'
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'aws-sdk-core'
4
+ require 'active_support/notifications'
5
+
6
+ module Aws
7
+ module Rails
8
+
9
+ # Instruments client operation calls for ActiveSupport::Notifications
10
+ # Each client operation will produce an event with name:
11
+ # <operation>.<service>.aws
12
+ # @api private
13
+ class Notifications < Seahorse::Client::Plugin
14
+
15
+ def add_handlers(handlers, config)
16
+ # This plugin needs to be first
17
+ # which means it is called first in the stack, to start recording time,
18
+ # and returns last
19
+ handlers.add(Handler, step: :initialize, priority: 99)
20
+ end
21
+
22
+ class Handler < Seahorse::Client::Handler
23
+
24
+ def call(context)
25
+ event_name = "#{context.operation_name}.#{context.config.api.metadata['serviceId']}.aws"
26
+ ActiveSupport::Notifications.instrument(event_name, context: context) do
27
+ @handler.call(context)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ # Use the Rails namespace.
5
+ module Rails
6
+ # @api private
7
+ class Railtie < ::Rails::Railtie
8
+ initializer 'aws-sdk-rails.initialize',
9
+ before: :load_config_initializers do
10
+ # Initialization Actions
11
+ Aws::Rails.use_rails_encrypted_credentials
12
+ Aws::Rails.add_action_mailer_delivery_method
13
+ Aws::Rails.log_to_rails_logger
14
+ end
15
+
16
+ rake_tasks do
17
+ load 'tasks/dynamo_db/session_store.rake'
18
+ end
19
+ end
20
+
21
+ # This is called automatically from the SDK's Railtie, but can be manually
22
+ # called if you want to specify options for building the Aws::SES::Client.
23
+ #
24
+ # @param [Symbol] name The name of the ActionMailer delivery method to
25
+ # register.
26
+ # @param [Hash] options The options you wish to pass on to the
27
+ # Aws::SES::Client initialization method.
28
+ def self.add_action_mailer_delivery_method(name = :ses, options = {})
29
+ ActiveSupport.on_load(:action_mailer) do
30
+ add_delivery_method(name, Aws::Rails::Mailer, options)
31
+ end
32
+ end
33
+
34
+ # Configures the AWS SDK for Ruby's logger to use the Rails logger.
35
+ def self.log_to_rails_logger
36
+ Aws.config[:logger] = ::Rails.logger
37
+ nil
38
+ end
39
+
40
+ # Configures the AWS SDK with credentials from Rails encrypted credentials.
41
+ def self.use_rails_encrypted_credentials
42
+ # limit the config keys we merge to credentials only
43
+ aws_credential_keys = %i[access_key_id secret_access_key session_token]
44
+
45
+ Aws.config.merge!(
46
+ ::Rails.application
47
+ .try(:credentials)
48
+ .try(:aws)
49
+ .to_h.slice(*aws_credential_keys)
50
+ )
51
+ end
52
+
53
+ # Adds ActiveSupport Notifications instrumentation to AWS SDK
54
+ # client operations. Each operation will produce an event with a name:
55
+ # <operation>.<service>.aws. For example, S3's put_object has an event
56
+ # name of: put_object.S3.aws
57
+ def self.instrument_sdk_operations
58
+ Aws.constants.each do |c|
59
+ m = Aws.const_get(c)
60
+ if m.is_a?(Module) && m.const_defined?(:Client) &&
61
+ m.const_get(:Client).superclass == Seahorse::Client::Base
62
+ m.const_get(:Client).add_plugin(Aws::Rails::Notifications)
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,46 @@
1
+ require 'rails/generators/named_base'
2
+
3
+ # This class generates a migration file for deleting and creating
4
+ # a DynamoDB sessions table.
5
+ module DynamoDb
6
+ module Generators
7
+ # Generates an ActiveRecord migration that creates and deletes a DynamoDB
8
+ # Session table.
9
+ class SessionStoreMigrationGenerator < Rails::Generators::NamedBase
10
+ include Rails::Generators::Migration
11
+
12
+ source_root File.expand_path('templates', __dir__)
13
+
14
+ # Desired name of migration class
15
+ argument :name, type: :string, default: 'create_dynamo_db_sessions_table'
16
+
17
+ # @return [Rails Migration File] migration file for creation and deletion
18
+ # of a DynamoDB session table.
19
+ def generate_migration_file
20
+ migration_template(
21
+ 'session_store_migration.rb',
22
+ "db/migrate/#{name.underscore}.rb"
23
+ )
24
+ end
25
+
26
+ def copy_sample_config_file
27
+ template(
28
+ 'dynamo_db_session_store.yml',
29
+ 'config/dynamo_db_session_store.yml'
30
+ )
31
+ end
32
+
33
+ # Next migration number - must be implemented
34
+ def self.next_migration_number(_dir = nil)
35
+ Time.now.utc.strftime('%Y%m%d%H%M%S')
36
+ end
37
+
38
+ private
39
+
40
+ # @return [String] activerecord migration version
41
+ def migration_version
42
+ "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}"
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,9 @@
1
+ class <%= name.camelize %> < ActiveRecord::Migration[<%= migration_version %>]
2
+ def up
3
+ Aws::SessionStore::DynamoDB::Table.create_table
4
+ end
5
+
6
+ def down
7
+ Aws::SessionStore::DynamoDB::Table.delete_table
8
+ end
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-06 00:00:00.000000000 Z
11
+ date: 2020-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-ses
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: aws-sessionstore-dynamodb
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: railties
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -54,19 +68,24 @@ dependencies:
54
68
  version: '0'
55
69
  description: Integrates the AWS Ruby SDK with Ruby on Rails
56
70
  email:
57
- - chejingy@amazon.com
58
71
  - mamuller@amazon.com
72
+ - alexwoo@amazon.com
59
73
  executables: []
60
74
  extensions: []
61
75
  extra_rdoc_files: []
62
76
  files:
77
+ - lib/action_dispatch/session/dynamodb_store.rb
63
78
  - lib/aws-sdk-rails.rb
64
79
  - lib/aws/rails/mailer.rb
80
+ - lib/aws/rails/notifications.rb
81
+ - lib/aws/rails/railtie.rb
82
+ - lib/generators/dynamo_db/session_store_migration/session_store_migration_generator.rb
83
+ - lib/generators/dynamo_db/session_store_migration/templates/session_store_migration.rb
65
84
  homepage: https://github.com/aws/aws-sdk-rails
66
85
  licenses:
67
86
  - Apache-2.0
68
87
  metadata: {}
69
- post_install_message:
88
+ post_install_message:
70
89
  rdoc_options: []
71
90
  require_paths:
72
91
  - lib
@@ -82,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
101
  version: '0'
83
102
  requirements: []
84
103
  rubygems_version: 3.0.3
85
- signing_key:
104
+ signing_key:
86
105
  specification_version: 4
87
106
  summary: AWS SDK for Ruby on Rails Plugin
88
107
  test_files: []