aws-sessionstore-dynamodb 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +32 -0
- data/.gitignore +1 -0
- data/.travis.yml +1 -3
- data/CHANGELOG.md +12 -0
- data/Gemfile +4 -0
- data/Rakefile +8 -11
- data/VERSION +1 -1
- data/aws-sessionstore-dynamodb.gemspec +2 -1
- data/doc-src/templates/default/layout/html/footer.erb +0 -4
- data/lib/aws/session_store/dynamo_db/configuration.rb +26 -40
- data/lib/aws/session_store/dynamo_db/locking/base.rb +1 -1
- data/lib/aws/session_store/dynamo_db/rack_middleware.rb +3 -0
- data/spec/aws/session_store/dynamo_db/app_config.yml +0 -3
- data/spec/aws/session_store/dynamo_db/configuration_spec.rb +6 -3
- data/spec/aws/session_store/dynamo_db/error/default_error_handler_spec.rb +1 -1
- data/spec/aws/session_store/dynamo_db/garbage_collection_spec.rb +4 -4
- data/spec/aws/session_store/dynamo_db/rack_middleware_spec.rb +2 -1
- metadata +10 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 567a54a1d54a1c4e00d6c85e98636320e6b1dcdddadf7acbeb1240244a32555e
|
4
|
+
data.tar.gz: 299b7c0b5780a980c963fe18c7f053919c8e7157ea092f0fbdfb88b263b39f5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b244ab47e504e446d268570f0fd54d47b6d142c31f17bb30053145f13aaea3a2a34f512841767fe9b0db2b5330983545e7e1c4b8209f309f95137f39762dc3a
|
7
|
+
data.tar.gz: 36d11102937288958a31899e99b8cd7d0e84e8e252bdc901e2a7d9514e74853ecd208c63217034c791b477eb83de058e06e0b790203fc5efc8aac94aa5b1bedc
|
@@ -0,0 +1,32 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
|
8
|
+
pull_request:
|
9
|
+
branches:
|
10
|
+
- main
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
test:
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
strategy:
|
16
|
+
fail-fast: false
|
17
|
+
matrix:
|
18
|
+
ruby: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, jruby-9.1, jruby-9.2, jruby-9.3, jruby-9.4]
|
19
|
+
|
20
|
+
steps:
|
21
|
+
- name: Setup
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
25
|
+
|
26
|
+
- uses: actions/checkout@v2
|
27
|
+
|
28
|
+
- name: Install
|
29
|
+
run: bundle install --without docs
|
30
|
+
|
31
|
+
- name: Test
|
32
|
+
run: bundle exec rake spec
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -5,8 +5,6 @@ branches:
|
|
5
5
|
language: ruby
|
6
6
|
|
7
7
|
rvm:
|
8
|
-
- 2.0
|
9
|
-
- 2.1
|
10
8
|
- 2.2
|
11
9
|
- 2.3
|
12
10
|
- 2.4
|
@@ -21,6 +19,6 @@ sudo: false
|
|
21
19
|
env:
|
22
20
|
- AWS_REGION=us-west-2
|
23
21
|
|
24
|
-
script: bundle exec rake
|
22
|
+
script: bundle exec rake spec
|
25
23
|
|
26
24
|
bundler_args: --without docs release repl
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
2.1.0 (2023-06-02)
|
2
|
+
------------------
|
3
|
+
|
4
|
+
* Feature - Improve User-Agent tracking and bump minimum DynamoDB version.
|
5
|
+
|
6
|
+
2.0.1 (2020-11-16)
|
7
|
+
------------------
|
8
|
+
|
9
|
+
* Issue - Expose `:config` in `RackMiddleware` and `:config_file` in `Configuration`.
|
10
|
+
|
11
|
+
* Issue - V2 of this release was still loading SDK V1 credential keys. This removes support for client options specified in YAML configuration (behavior change). Instead, construct `Aws::DynamoDB::Client` and use the `dynamo_db_client` option.
|
12
|
+
|
1
13
|
2.0.0 (2020-11-11)
|
2
14
|
------------------
|
3
15
|
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
|
1
3
|
$REPO_ROOT = File.dirname(__FILE__)
|
2
4
|
$LOAD_PATH.unshift(File.join($REPO_ROOT, 'lib'))
|
3
5
|
$VERSION = ENV['VERSION'] || File.read(File.join($REPO_ROOT, 'VERSION')).strip
|
4
6
|
|
5
|
-
require 'rspec/core/rake_task'
|
6
7
|
|
7
8
|
Dir.glob('**/*.rake').each do |task_file|
|
8
9
|
load task_file
|
@@ -12,27 +13,23 @@ task 'test:coverage:clear' do
|
|
12
13
|
sh("rm -rf #{File.join($REPO_ROOT, 'coverage')}")
|
13
14
|
end
|
14
15
|
|
15
|
-
# Override the test task definitions
|
16
|
-
# this package uses rspec tags to define integration tests
|
17
|
-
Rake::Task["test:unit"].clear
|
18
16
|
desc 'Runs unit tests'
|
19
|
-
RSpec::Core::RakeTask.new
|
17
|
+
RSpec::Core::RakeTask.new do |t|
|
20
18
|
t.rspec_opts = "-I #{$REPO_ROOT}/lib -I #{$REPO_ROOT}/spec --tag ~integration"
|
21
19
|
t.pattern = "#{$REPO_ROOT}/spec"
|
22
20
|
end
|
23
|
-
task
|
21
|
+
task :spec => 'test:coverage:clear'
|
24
22
|
|
25
|
-
Rake::Task["test:integration"].clear
|
26
23
|
desc 'Runs integration tests'
|
27
|
-
RSpec::Core::RakeTask.new('
|
24
|
+
RSpec::Core::RakeTask.new('spec:integration') do |t|
|
28
25
|
t.rspec_opts = "-I #{$REPO_ROOT}/lib -I #{$REPO_ROOT}/spec --tag integration"
|
29
26
|
t.pattern = "#{$REPO_ROOT}/spec"
|
30
27
|
end
|
31
|
-
task 'test:integration' => 'test:coverage:clear'
|
32
28
|
|
33
29
|
desc 'Runs unit and integration tests'
|
34
|
-
task 'test' => [
|
30
|
+
task 'test' => [:spec, 'spec:integration']
|
35
31
|
|
36
|
-
task :default =>
|
32
|
+
task :default => :spec
|
33
|
+
task 'release:test' => [:spec, 'spec:integration']
|
37
34
|
|
38
35
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.1.0
|
@@ -15,6 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
16
|
spec.require_paths = ["lib"]
|
17
17
|
|
18
|
-
|
18
|
+
# Require 1.85.0 for user_agent_frameworks config
|
19
|
+
spec.add_dependency 'aws-sdk-dynamodb', '~> 1', '>= 1.85.0'
|
19
20
|
spec.add_dependency 'rack', '~> 2'
|
20
21
|
end
|
@@ -4,7 +4,3 @@
|
|
4
4
|
<%= YARD::VERSION %> (ruby-<%= RUBY_VERSION %>).
|
5
5
|
<div id="awsdocs-legal-zone-copyright"></div>
|
6
6
|
</div>
|
7
|
-
|
8
|
-
<!-- Gitter chat -->
|
9
|
-
<script>((window.gitter = {}).chat = {}).options = { room: 'aws/aws-sdk-ruby' };</script>
|
10
|
-
<script src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer></script>
|
@@ -56,6 +56,8 @@ module Aws::SessionStore::DynamoDB
|
|
56
56
|
:secret_key => nil
|
57
57
|
}
|
58
58
|
|
59
|
+
### Feature options
|
60
|
+
|
59
61
|
# @return [String] Session table name.
|
60
62
|
attr_reader :table_name
|
61
63
|
|
@@ -84,14 +86,6 @@ module Aws::SessionStore::DynamoDB
|
|
84
86
|
# ErrorHandler is used.
|
85
87
|
attr_reader :raise_errors
|
86
88
|
|
87
|
-
# @return [DynamoDB Client] DynamoDB client.
|
88
|
-
attr_reader :dynamo_db_client
|
89
|
-
|
90
|
-
# @return [Error Handler] An error handling object that handles all exceptions
|
91
|
-
# thrown during execution of the AWS DynamoDB Session Store Rack Middleware.
|
92
|
-
# For more information see the Handling Errors Section.
|
93
|
-
attr_reader :error_handler
|
94
|
-
|
95
89
|
# @return [Integer] Maximum number of seconds earlier
|
96
90
|
# from the current time that a session was created.
|
97
91
|
attr_reader :max_age
|
@@ -100,9 +94,6 @@ module Aws::SessionStore::DynamoDB
|
|
100
94
|
# before the current time that the session was last accessed.
|
101
95
|
attr_reader :max_stale
|
102
96
|
|
103
|
-
# @return [String] The secret key for HMAC encryption.
|
104
|
-
attr_reader :secret_key
|
105
|
-
|
106
97
|
# @return [true] Pessimistic locking strategy will be implemented for
|
107
98
|
# all session accesses.
|
108
99
|
# @return [false] No locking strategy will be implemented for
|
@@ -120,6 +111,21 @@ module Aws::SessionStore::DynamoDB
|
|
120
111
|
# before giving up.
|
121
112
|
attr_reader :lock_max_wait_time
|
122
113
|
|
114
|
+
# @return [String] The secret key for HMAC encryption.
|
115
|
+
attr_reader :secret_key
|
116
|
+
|
117
|
+
# @return [String,Pathname]
|
118
|
+
attr_reader :config_file
|
119
|
+
|
120
|
+
### Client and Error Handling options
|
121
|
+
|
122
|
+
# @return [DynamoDB Client] DynamoDB client.
|
123
|
+
attr_reader :dynamo_db_client
|
124
|
+
|
125
|
+
# @return [Error Handler] An error handling object that handles all exceptions
|
126
|
+
# thrown during execution of the AWS DynamoDB Session Store Rack Middleware.
|
127
|
+
# For more information see the Handling Errors Section.
|
128
|
+
attr_reader :error_handler
|
123
129
|
|
124
130
|
# Provides configuration object that allows access to options defined
|
125
131
|
# during Runtime, in a YAML file, in the ENV and by default.
|
@@ -163,18 +169,16 @@ module Aws::SessionStore::DynamoDB
|
|
163
169
|
# @option options [Integer] :lock_retry_delay (500) Time in milleseconds to
|
164
170
|
# wait before retrying to obtain lock once an attempt to obtain lock
|
165
171
|
# has been made and has failed.
|
166
|
-
# @option options [Integer] :lock_max_wait_time (500) Maximum time
|
167
|
-
# to wait to acquire lock before giving up.
|
172
|
+
# @option options [Integer] :lock_max_wait_time (500) Maximum time
|
173
|
+
# in seconds to wait to acquire lock before giving up.
|
168
174
|
# @option options [String] :secret_key (SecureRandom.hex(64))
|
169
175
|
# Secret key for HMAC encription.
|
170
176
|
def initialize(options = {})
|
171
177
|
@options = default_options.merge(
|
172
|
-
|
173
|
-
file_options(options).merge(
|
174
|
-
|
175
|
-
|
176
|
-
)
|
177
|
-
)
|
178
|
+
env_options.merge(
|
179
|
+
file_options(options).merge(symbolize_keys(options))
|
180
|
+
)
|
181
|
+
)
|
178
182
|
@options = client_error.merge(@options)
|
179
183
|
set_attributes(@options)
|
180
184
|
end
|
@@ -188,10 +192,9 @@ module Aws::SessionStore::DynamoDB
|
|
188
192
|
|
189
193
|
# @return [Hash] DDB client.
|
190
194
|
def gen_dynamo_db_client
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
dynamo_db_client = @options[:dynamo_db_client] || client.new(client_opts)
|
195
|
+
dynamo_db_client = @options[:dynamo_db_client] || Aws::DynamoDB::Client.new
|
196
|
+
# this used to be aws-sessionstore/version on user_agent_suffix
|
197
|
+
dynamo_db_client.config.user_agent_frameworks << "aws-sessionstore-dynamodb"
|
195
198
|
{:dynamo_db_client => dynamo_db_client}
|
196
199
|
end
|
197
200
|
|
@@ -258,22 +261,5 @@ module Aws::SessionStore::DynamoDB
|
|
258
261
|
opts
|
259
262
|
end
|
260
263
|
end
|
261
|
-
|
262
|
-
# @return [Hash] Client subset options hash.
|
263
|
-
def client_subset(options = {})
|
264
|
-
client_keys = [:aws_secret_key, :aws_region, :aws_access_key, :api_version]
|
265
|
-
options.inject({}) do |opts, (opt_name, opt_value)|
|
266
|
-
opts[opt_name.to_sym] = opt_value if client_keys.include?(opt_name.to_sym)
|
267
|
-
opts
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
def _user_agent(custom)
|
272
|
-
if custom
|
273
|
-
custom
|
274
|
-
else
|
275
|
-
" aws-sessionstore/#{VERSION}"
|
276
|
-
end
|
277
|
-
end
|
278
264
|
end
|
279
265
|
end
|
@@ -14,7 +14,7 @@ module Aws::SessionStore::DynamoDB::Locking
|
|
14
14
|
packed_session = pack_data(session)
|
15
15
|
handle_error(env) do
|
16
16
|
save_opts = update_opts(env, sid, packed_session, options)
|
17
|
-
|
17
|
+
@config.dynamo_db_client.update_item(save_opts)
|
18
18
|
sid
|
19
19
|
end
|
20
20
|
end
|
@@ -6,6 +6,9 @@ module Aws::SessionStore::DynamoDB
|
|
6
6
|
# This class is an ID based Session Store Rack Middleware
|
7
7
|
# that uses a DynamoDB backend for session storage.
|
8
8
|
class RackMiddleware < Rack::Session::Abstract::Persisted
|
9
|
+
# @return [Configuration] An instance of Configuration that is used for
|
10
|
+
# this middleware.
|
11
|
+
attr_reader :config
|
9
12
|
|
10
13
|
# Initializes SessionStore middleware.
|
11
14
|
#
|
@@ -30,14 +30,13 @@ describe Aws::SessionStore::DynamoDB::Configuration do
|
|
30
30
|
let(:expected_file_opts) do
|
31
31
|
{
|
32
32
|
consistent_read: true,
|
33
|
-
AWS_ACCESS_KEY_ID: 'FakeKey',
|
34
|
-
AWS_REGION: 'New York',
|
35
33
|
table_name: 'NewTable',
|
36
34
|
table_key: 'Somekey',
|
37
|
-
AWS_SECRET_ACCESS_KEY: 'Secret'
|
38
35
|
}
|
39
36
|
end
|
40
37
|
|
38
|
+
let(:client) { Aws::DynamoDB::Client.new(stub_responses: true) }
|
39
|
+
|
41
40
|
let(:runtime_options) do
|
42
41
|
{
|
43
42
|
table_name: 'SessionTable',
|
@@ -51,6 +50,10 @@ describe Aws::SessionStore::DynamoDB::Configuration do
|
|
51
50
|
expect(cfg.to_hash).to include(expected_opts)
|
52
51
|
end
|
53
52
|
|
53
|
+
before do
|
54
|
+
allow(Aws::DynamoDB::Client).to receive(:new).and_return(client)
|
55
|
+
end
|
56
|
+
|
54
57
|
context 'Configuration Tests' do
|
55
58
|
it 'configures option with out runtime,YAML or ENV options' do
|
56
59
|
cfg = Aws::SessionStore::DynamoDB::Configuration.new
|
@@ -26,7 +26,7 @@ describe Aws::SessionStore::DynamoDB do
|
|
26
26
|
|
27
27
|
let(:base_app) { MultiplierApplication.new }
|
28
28
|
let(:app) { Aws::SessionStore::DynamoDB::RackMiddleware.new(base_app, @options) }
|
29
|
-
let(:client) { double('Aws::DynamoDB::Client') }
|
29
|
+
let(:client) { double('Aws::DynamoDB::Client', config: double(user_agent_frameworks: [])) }
|
30
30
|
|
31
31
|
context 'Error handling for Rack Middleware with default error handler' do
|
32
32
|
it 'raises error for missing secret key' do
|
@@ -98,7 +98,7 @@ describe Aws::SessionStore::DynamoDB::GarbageCollection do
|
|
98
98
|
}
|
99
99
|
end
|
100
100
|
|
101
|
-
let(:dynamo_db_client) {Aws::DynamoDB::Client.new}
|
101
|
+
let(:dynamo_db_client) {Aws::DynamoDB::Client.new(stub_responses: true)}
|
102
102
|
|
103
103
|
context 'Mock DynamoDB client with garbage collection' do
|
104
104
|
it 'processes scan result greater than 25 and deletes in batches of 25' do
|
@@ -124,9 +124,9 @@ describe Aws::SessionStore::DynamoDB::GarbageCollection do
|
|
124
124
|
expect(dynamo_db_client).to receive(:scan).
|
125
125
|
exactly(1).times.and_return(scan_resp3)
|
126
126
|
expect(dynamo_db_client).to receive(:batch_write_item).ordered.
|
127
|
-
with(request_items: { 'sessions' => format_scan_result }).
|
127
|
+
with({request_items: { 'sessions' => format_scan_result }}).
|
128
128
|
and_return(write_resp2)
|
129
|
-
expect(dynamo_db_client).to receive(:batch_write_item).ordered.with(
|
129
|
+
expect(dynamo_db_client).to receive(:batch_write_item).ordered.with({
|
130
130
|
request_items: {
|
131
131
|
'sessions' => [
|
132
132
|
{
|
@@ -151,7 +151,7 @@ describe Aws::SessionStore::DynamoDB::GarbageCollection do
|
|
151
151
|
}
|
152
152
|
]
|
153
153
|
}
|
154
|
-
).and_return(write_resp1)
|
154
|
+
}).and_return(write_resp1)
|
155
155
|
collect_garbage
|
156
156
|
end
|
157
157
|
end
|
@@ -53,7 +53,8 @@ module Aws
|
|
53
53
|
delete_item: 'Deleted',
|
54
54
|
list_tables: { table_names: ['Sessions'] },
|
55
55
|
get_item: { item: { 'data' => sample_packed_data } },
|
56
|
-
update_item: { attributes: { created_at: 'now' } }
|
56
|
+
update_item: { attributes: { created_at: 'now' } },
|
57
|
+
config: double(user_agent_frameworks: [])
|
57
58
|
)
|
58
59
|
end
|
59
60
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-sessionstore-dynamodb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amazon Web Services
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-dynamodb
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.85.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '1'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.85.0
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: rack
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -47,6 +53,7 @@ extensions: []
|
|
47
53
|
extra_rdoc_files: []
|
48
54
|
files:
|
49
55
|
- ".github/PULL_REQUEST_TEMPLATE.md"
|
56
|
+
- ".github/workflows/ci.yml"
|
50
57
|
- ".gitignore"
|
51
58
|
- ".gitmodules"
|
52
59
|
- ".travis.yml"
|
@@ -104,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
111
|
- !ruby/object:Gem::Version
|
105
112
|
version: '0'
|
106
113
|
requirements: []
|
107
|
-
rubygems_version: 3.
|
114
|
+
rubygems_version: 3.4.10
|
108
115
|
signing_key:
|
109
116
|
specification_version: 4
|
110
117
|
summary: The Amazon DynamoDB Session Store handles sessions for Ruby web applications
|