aws-sessionstore-dynamodb 3.0.0 → 3.0.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/{LICENSE.txt → LICENSE} +0 -27
- data/VERSION +1 -1
- data/lib/aws/session_store/dynamo_db/configuration.rb +30 -19
- data/lib/aws/session_store/dynamo_db/errors/base_handler.rb +3 -3
- data/lib/aws/session_store/dynamo_db/garbage_collection.rb +1 -0
- data/lib/aws/session_store/dynamo_db/locking.rb +10 -0
- data/lib/aws-sessionstore-dynamodb.rb +1 -3
- metadata +22 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c47a85cf680544f7ae67c8001202f12183ef7c820ae2a08807ae577b43ab610a
|
4
|
+
data.tar.gz: fe33ca1aaf6a21a3e12064290c329184ed071bde6765103c656ecbb200334d37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 525409e21cd2766373652e93bd7f5284b6e8f277a6715b06f126dcfa3286cb26882665786e4cb8c9d06c4b5bf202334b6dde66e25ddf6ba79dc1afc0ac19c165
|
7
|
+
data.tar.gz: 2842691bc6bda28038e4bf93fb63672b06aba06bcbc09b7a82d1a851ab58388bd13f33b62bef804963fba73b57a0169257a875be1e57ee3fbde125084bdc8c8e
|
data/CHANGELOG.md
CHANGED
data/{LICENSE.txt → LICENSE}
RENAMED
@@ -173,30 +173,3 @@
|
|
173
173
|
defend, and hold each Contributor harmless for any liability
|
174
174
|
incurred by, or claims asserted against, such Contributor by reason
|
175
175
|
of your accepting any such warranty or additional liability.
|
176
|
-
|
177
|
-
END OF TERMS AND CONDITIONS
|
178
|
-
|
179
|
-
APPENDIX: How to apply the Apache License to your work.
|
180
|
-
|
181
|
-
To apply the Apache License to your work, attach the following
|
182
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
-
replaced with your own identifying information. (Don't include
|
184
|
-
the brackets!) The text should be enclosed in the appropriate
|
185
|
-
comment syntax for the file format. We also recommend that a
|
186
|
-
file or class name and description of purpose be included on the
|
187
|
-
same "printed page" as the copyright notice for easier
|
188
|
-
identification within third-party archives.
|
189
|
-
|
190
|
-
Copyright [yyyy] [name of copyright owner]
|
191
|
-
|
192
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
-
you may not use this file except in compliance with the License.
|
194
|
-
You may obtain a copy of the License at
|
195
|
-
|
196
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
-
|
198
|
-
Unless required by applicable law or agreed to in writing, software
|
199
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
-
See the License for the specific language governing permissions and
|
202
|
-
limitations under the License.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0.
|
1
|
+
3.0.1
|
@@ -4,25 +4,25 @@ require 'aws-sdk-dynamodb'
|
|
4
4
|
|
5
5
|
module Aws::SessionStore::DynamoDB
|
6
6
|
# This class provides a Configuration object for all DynamoDB session store operations
|
7
|
-
# by pulling configuration options from Runtime, a YAML file,
|
7
|
+
# by pulling configuration options from Runtime, the ENV, a YAML file, and default
|
8
8
|
# settings, in that order.
|
9
9
|
#
|
10
|
-
#
|
10
|
+
# # Environment Variables
|
11
11
|
# The Configuration object can load default values from your environment. All configuration
|
12
12
|
# keys are supported except for `:dynamo_db_client` and `:error_handler`. The keys take the form
|
13
|
-
# of
|
13
|
+
# of AWS_DYNAMO_DB_SESSION_<KEY_NAME>. Example:
|
14
14
|
#
|
15
|
-
#
|
16
|
-
#
|
15
|
+
# export AWS_DYNAMO_DB_SESSION_TABLE_NAME='Sessions'
|
16
|
+
# export AWS_DYNAMO_DB_SESSION_TABLE_KEY='id'
|
17
17
|
#
|
18
|
-
#
|
18
|
+
# # Locking Strategy
|
19
19
|
# By default, locking is disabled for session store access. To enable locking, set the
|
20
20
|
# `:enable_locking` option to true. The locking strategy is pessimistic, meaning that only one
|
21
21
|
# read can be made on a session at once. While the session is being read by the process with the
|
22
22
|
# lock, other processes may try to obtain a lock on the same session but will be blocked.
|
23
23
|
# See the initializer for how to configure the pessimistic locking strategy to your needs.
|
24
24
|
#
|
25
|
-
#
|
25
|
+
# # Handling Errors
|
26
26
|
# There are two configurable options for error handling: `:raise_errors` and `:error_handler`.
|
27
27
|
#
|
28
28
|
# If you would like to use the Default Error Handler, you can decide to set `:raise_errors`
|
@@ -33,12 +33,12 @@ module Aws::SessionStore::DynamoDB
|
|
33
33
|
# class and pass it into the `:error_handler` option.
|
34
34
|
# @see BaseHandler Interface for Error Handling for DynamoDB Session Store.
|
35
35
|
#
|
36
|
-
#
|
36
|
+
# # DynamoDB Specific Options
|
37
37
|
# You may configure the table name and table hash key value of your session table with
|
38
38
|
# the `:table_name` and `:table_key` options. You may also configure performance options for
|
39
39
|
# your table with the `:consistent_read`, `:read_capacity`, `:write_capacity`. For more information
|
40
40
|
# about these configurations see
|
41
|
-
# {https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#create_table-instance_method CreateTable
|
41
|
+
# {https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#create_table-instance_method CreateTable}
|
42
42
|
# method for Amazon DynamoDB.
|
43
43
|
#
|
44
44
|
class Configuration
|
@@ -63,7 +63,7 @@ module Aws::SessionStore::DynamoDB
|
|
63
63
|
}.freeze
|
64
64
|
|
65
65
|
# Provides configuration object that allows access to options defined
|
66
|
-
# during Runtime, in
|
66
|
+
# during Runtime, in the ENV, in a YAML file, and by default.
|
67
67
|
#
|
68
68
|
# @option options [String] :table_name ("sessions") Name of the session table.
|
69
69
|
# @option options [String] :table_key ("session_id") The hash key of the session table.
|
@@ -99,8 +99,9 @@ module Aws::SessionStore::DynamoDB
|
|
99
99
|
# @option options [Aws::DynamoDB::Client] :dynamo_db_client (Aws::DynamoDB::Client.new)
|
100
100
|
# DynamoDB client used to perform database operations inside of the rack application.
|
101
101
|
def initialize(options = {})
|
102
|
-
opts =
|
102
|
+
opts = options
|
103
103
|
opts = env_options.merge(opts)
|
104
|
+
opts = file_options(opts).merge(opts)
|
104
105
|
MEMBERS.each_pair do |opt_name, default_value|
|
105
106
|
opts[opt_name] = default_value unless opts.key?(opt_name)
|
106
107
|
end
|
@@ -137,21 +138,30 @@ module Aws::SessionStore::DynamoDB
|
|
137
138
|
def env_options
|
138
139
|
unsupported_keys = %i[dynamo_db_client error_handler]
|
139
140
|
(MEMBERS.keys - unsupported_keys).each_with_object({}) do |opt_name, opts|
|
140
|
-
key =
|
141
|
+
key = env_key(opt_name)
|
141
142
|
next unless ENV.key?(key)
|
142
143
|
|
143
144
|
opts[opt_name] = parse_env_value(key)
|
144
145
|
end
|
145
146
|
end
|
146
147
|
|
147
|
-
def
|
148
|
-
|
149
|
-
|
150
|
-
if ENV
|
151
|
-
|
148
|
+
def env_key(opt_name)
|
149
|
+
# legacy - remove this in aws-sessionstore-dynamodb ~> 4
|
150
|
+
key = "DYNAMO_DB_SESSION_#{opt_name.to_s.upcase}"
|
151
|
+
if ENV.key?(key)
|
152
|
+
Kernel.warn("The environment variable `#{key}` is deprecated.
|
153
|
+
Please use `AWS_DYNAMO_DB_SESSION_#{opt_name.to_s.upcase}` instead.")
|
152
154
|
else
|
153
|
-
|
155
|
+
key = "AWS_DYNAMO_DB_SESSION_#{opt_name.to_s.upcase}"
|
154
156
|
end
|
157
|
+
key
|
158
|
+
end
|
159
|
+
|
160
|
+
def parse_env_value(key)
|
161
|
+
val = ENV.fetch(key, nil)
|
162
|
+
Integer(val)
|
163
|
+
rescue ArgumentError
|
164
|
+
%w[true false].include?(val) ? val == 'true' : val
|
155
165
|
end
|
156
166
|
|
157
167
|
# @return [Hash] File options.
|
@@ -168,7 +178,8 @@ module Aws::SessionStore::DynamoDB
|
|
168
178
|
require 'erb'
|
169
179
|
require 'yaml'
|
170
180
|
opts = YAML.safe_load(ERB.new(File.read(file_path)).result) || {}
|
171
|
-
|
181
|
+
unsupported_keys = %i[dynamo_db_client error_handler config_file]
|
182
|
+
opts.transform_keys(&:to_sym).reject { |k, _| unsupported_keys.include?(k) }
|
172
183
|
end
|
173
184
|
|
174
185
|
def set_attributes(options)
|
@@ -6,7 +6,7 @@ module Aws::SessionStore::DynamoDB::Errors
|
|
6
6
|
# Each error handler must implement a handle_error method.
|
7
7
|
#
|
8
8
|
# @example Sample ErrorHandler class
|
9
|
-
# class MyErrorHandler <
|
9
|
+
# class MyErrorHandler < BaseHandler
|
10
10
|
# # Handles error passed in
|
11
11
|
# def handle_error(e, env = {})
|
12
12
|
# File.open(path_to_file, 'w') {|f| f.write(e.message) }
|
@@ -17,7 +17,7 @@ module Aws::SessionStore::DynamoDB::Errors
|
|
17
17
|
# An error and an environment (optionally) will be passed in to
|
18
18
|
# this method and it will determine how to deal
|
19
19
|
# with the error.
|
20
|
-
# Must return false if you have handled the error but are not
|
20
|
+
# Must return false if you have handled the error but are not re-raising the
|
21
21
|
# error up the stack.
|
22
22
|
# You may reraise the error passed.
|
23
23
|
#
|
@@ -25,7 +25,7 @@ module Aws::SessionStore::DynamoDB::Errors
|
|
25
25
|
# Aws::SessionStore::DynamoDB::RackMiddleware.
|
26
26
|
# @param [Rack::Request::Environment,nil] env Rack environment
|
27
27
|
# @return [false] If exception was handled and will not reraise exception.
|
28
|
-
# @raise [Aws::DynamoDB::Errors] If error has be
|
28
|
+
# @raise [Aws::DynamoDB::Errors] If error has be re-raised.
|
29
29
|
def handle_error(error, env = {})
|
30
30
|
raise NotImplementedError
|
31
31
|
end
|
@@ -9,6 +9,7 @@ module Aws::SessionStore::DynamoDB
|
|
9
9
|
class << self
|
10
10
|
# Scans DynamoDB session table to find sessions that match the max age and
|
11
11
|
# max stale period requirements. it then deletes all of the found sessions.
|
12
|
+
# @option (see Configuration#initialize)
|
12
13
|
def collect_garbage(options = {})
|
13
14
|
config = load_config(options)
|
14
15
|
last_key = eliminate_unwanted_sessions(config)
|
@@ -12,8 +12,6 @@ end
|
|
12
12
|
require_relative 'aws/session_store/dynamo_db/configuration'
|
13
13
|
require_relative 'aws/session_store/dynamo_db/errors'
|
14
14
|
require_relative 'aws/session_store/dynamo_db/garbage_collection'
|
15
|
-
require_relative 'aws/session_store/dynamo_db/locking
|
16
|
-
require_relative 'aws/session_store/dynamo_db/locking/null'
|
17
|
-
require_relative 'aws/session_store/dynamo_db/locking/pessimistic'
|
15
|
+
require_relative 'aws/session_store/dynamo_db/locking'
|
18
16
|
require_relative 'aws/session_store/dynamo_db/rack_middleware'
|
19
17
|
require_relative 'aws/session_store/dynamo_db/table'
|
metadata
CHANGED
@@ -1,64 +1,65 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-sessionstore-dynamodb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
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: 2024-
|
11
|
+
date: 2024-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 1.85.0
|
19
|
+
version: '3'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 1.85.0
|
26
|
+
version: '3'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
|
-
name: rack
|
28
|
+
name: rack-session
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
31
|
- - "~>"
|
38
32
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
33
|
+
version: '2'
|
40
34
|
type: :runtime
|
41
35
|
prerelease: false
|
42
36
|
version_requirements: !ruby/object:Gem::Requirement
|
43
37
|
requirements:
|
44
38
|
- - "~>"
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
40
|
+
version: '2'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
42
|
+
name: aws-sdk-dynamodb
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
50
44
|
requirements:
|
51
45
|
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
47
|
+
version: '1'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 1.85.0
|
54
51
|
type: :runtime
|
55
52
|
prerelease: false
|
56
53
|
version_requirements: !ruby/object:Gem::Requirement
|
57
54
|
requirements:
|
58
55
|
- - "~>"
|
59
56
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
61
|
-
|
57
|
+
version: '1'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 1.85.0
|
61
|
+
description: The Amazon DynamoDB Session Store handles sessions for Rack web applications
|
62
|
+
using a DynamoDB backend.
|
62
63
|
email:
|
63
64
|
|
64
65
|
executables: []
|
@@ -66,7 +67,7 @@ extensions: []
|
|
66
67
|
extra_rdoc_files: []
|
67
68
|
files:
|
68
69
|
- CHANGELOG.md
|
69
|
-
- LICENSE
|
70
|
+
- LICENSE
|
70
71
|
- VERSION
|
71
72
|
- lib/aws-sessionstore-dynamodb.rb
|
72
73
|
- lib/aws/session_store/dynamo_db/configuration.rb
|
@@ -74,6 +75,7 @@ files:
|
|
74
75
|
- lib/aws/session_store/dynamo_db/errors/base_handler.rb
|
75
76
|
- lib/aws/session_store/dynamo_db/errors/default_handler.rb
|
76
77
|
- lib/aws/session_store/dynamo_db/garbage_collection.rb
|
78
|
+
- lib/aws/session_store/dynamo_db/locking.rb
|
77
79
|
- lib/aws/session_store/dynamo_db/locking/base.rb
|
78
80
|
- lib/aws/session_store/dynamo_db/locking/null.rb
|
79
81
|
- lib/aws/session_store/dynamo_db/locking/pessimistic.rb
|
@@ -101,6 +103,5 @@ requirements: []
|
|
101
103
|
rubygems_version: 3.5.11
|
102
104
|
signing_key:
|
103
105
|
specification_version: 4
|
104
|
-
summary:
|
105
|
-
using a DynamoDB backend.
|
106
|
+
summary: Amazon DynamoDB Session Store for Rack web applications.
|
106
107
|
test_files: []
|