aws-sdk-rails 2.0.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
- SHA1:
3
- metadata.gz: 0cb7c2fb3548b24522a39f7198022577a23b0c81
4
- data.tar.gz: 113bf55ef5e63b1a62d49cb311d0d1f30d13786e
2
+ SHA256:
3
+ metadata.gz: 68ff55530ced9007dd1eaa522efe123f6d809a5201d276d373d11171d1904e5b
4
+ data.tar.gz: 9f632d07b8eae350793893c4b002b0521ea81344c1ca2c0d06ad4a233281635d
5
5
  SHA512:
6
- metadata.gz: fc2f3865e396476b4b39115fb7b8439e410713afeb265e3f6b71b2cf2e5aa87fc41bbb532e03dc9c6e18c952ad3bfb82ae2d966e4f29b70b523309f0c76bab7c
7
- data.tar.gz: d553e23b153945f701b8c827abd04715d4c359f5b71d5b98a0b0a0608248233af5bbc8c7632c9938907fb126303d561b74e66801af2c9a1a60507adb023aa8be
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,37 +1,7 @@
1
- require_relative 'aws/rails/mailer'
2
-
3
- module Aws
4
- module Rails
5
-
6
- # @api private
7
- class Railtie < ::Rails::Railtie
8
- initializer "aws-sdk-rails.initialize" do |app|
9
- # Initialization Actions
10
- Aws::Rails.add_action_mailer_delivery_method
11
- Aws::Rails.log_to_rails_logger
12
- end
13
- end
1
+ # frozen_string_literal: true
14
2
 
15
- # This is called automatically from the SDK's Railtie, but if you want to
16
- # manually specify options for building the Aws::SES::Client object, you
17
- # can manually call this method.
18
- #
19
- # @param [Symbol] name The name of the ActionMailer delivery method to
20
- # register.
21
- # @param [Hash] options The options you wish to pass on to the
22
- # Aws::SES::Client initialization method.
23
- def self.add_action_mailer_delivery_method(name = :aws_sdk, options = {})
24
- ActiveSupport.on_load(:action_mailer) do
25
- self.add_delivery_method(name, Aws::Rails::Mailer, options)
26
- end
27
- end
28
-
29
- # Configures the AWS SDK for Ruby's logger to use the Rails logger.
30
- def self.log_to_rails_logger
31
- Aws.config[:logger] = ::Rails.logger
32
- nil
33
- end
34
-
35
- end
36
- end
3
+ require_relative 'aws/rails/mailer'
4
+ require_relative 'aws/rails/railtie'
5
+ require_relative 'aws/rails/notifications'
37
6
 
7
+ require_relative 'action_dispatch/session/dynamodb_store'
@@ -1,23 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'aws-sdk-ses'
2
4
 
3
5
  module Aws
4
6
  module Rails
5
-
6
7
  # Provides a delivery method for ActionMailer that uses Amazon Simple Email
7
8
  # Service.
8
- #
9
+ #
9
10
  # Once you have an SES delivery method you can configure Rails to
10
11
  # use this for ActionMailer in your environment configuration
11
12
  # (e.g. RAILS_ROOT/config/environments/production.rb)
12
13
  #
13
- # config.action_mailer.delivery_method = :aws_sdk
14
+ # config.action_mailer.delivery_method = :ses
14
15
  #
15
- # Uses the AWS SDK for Ruby V2's credential provider chain when creating an
16
- # SES client instance.
16
+ # Uses the AWS SDK for Ruby's credential provider chain when creating an SES
17
+ # client instance.
17
18
  class Mailer
18
-
19
19
  # @param [Hash] options Passes along initialization options to
20
- # [Aws::SES::Client.new](http://docs.aws.amazon.com/sdkforruby/api/Aws/SES/Client.html#initialize-instance_method).
20
+ # [Aws::SES::Client.new](https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/SES/Client.html#initialize-instance_method).
21
21
  def initialize(options = {})
22
22
  @client = SES::Client.new(options)
23
23
  end
@@ -33,15 +33,15 @@ module Aws
33
33
  send_opts[:destinations] = message.destinations
34
34
  end
35
35
 
36
- @client.send_raw_email(send_opts)
37
-
36
+ @client.send_raw_email(send_opts).tap do |response|
37
+ message.header[:ses_message_id] = response.message_id
38
+ end
38
39
  end
39
40
 
40
41
  # ActionMailer expects this method to be present and to return a hash.
41
42
  def settings
42
43
  {}
43
44
  end
44
-
45
45
  end
46
46
  end
47
47
  end
@@ -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: 2.0.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: 2017-08-29 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,34 +24,68 @@ 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
30
44
  requirements:
31
45
  - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: '3'
47
+ version: 5.2.0
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - ">="
39
53
  - !ruby/object:Gem::Version
40
- version: '3'
41
- description: Provides helpers to integrate the AWS SDK for Ruby with Ruby on Rails.
54
+ version: 5.2.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Integrates the AWS Ruby SDK with Ruby on Rails
42
70
  email:
43
- - alexwood@amazon.com
71
+ - mamuller@amazon.com
72
+ - alexwoo@amazon.com
44
73
  executables: []
45
74
  extensions: []
46
75
  extra_rdoc_files: []
47
76
  files:
77
+ - lib/action_dispatch/session/dynamodb_store.rb
48
78
  - lib/aws-sdk-rails.rb
49
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
50
84
  homepage: https://github.com/aws/aws-sdk-rails
51
85
  licenses:
52
- - Apache 2.0
86
+ - Apache-2.0
53
87
  metadata: {}
54
- post_install_message:
88
+ post_install_message:
55
89
  rdoc_options: []
56
90
  require_paths:
57
91
  - lib
@@ -66,9 +100,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
100
  - !ruby/object:Gem::Version
67
101
  version: '0'
68
102
  requirements: []
69
- rubyforge_project:
70
- rubygems_version: 2.5.1
71
- signing_key:
103
+ rubygems_version: 3.0.3
104
+ signing_key:
72
105
  specification_version: 4
73
- summary: AWS SDK for Ruby Rails Plugin
106
+ summary: AWS SDK for Ruby on Rails Plugin
74
107
  test_files: []