@@ -56,6 +56,8 @@ class Configuration
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 @@ class Configuration
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 @@ class Configuration
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 @@ class Configuration
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 @@ class Configuration
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 in seconds
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
- env_options . merge (
173
- file_options ( options ) . merge (
174
- symbolize_keys ( options )
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,8 +192,7 @@ def to_hash
188
192
189
193
# @return [Hash] DDB client.
190
194
def gen_dynamo_db_client
191
- client_opts = client_subset ( @options )
192
- client_opts [ :user_agent_suffix ] = _user_agent ( @options . delete ( :user_agent_suffix ) )
195
+ client_opts = { user_agent_suffix : " aws-sessionstore/#{ VERSION } " }
193
196
client = Aws ::DynamoDB ::Client
194
197
dynamo_db_client = @options [ :dynamo_db_client ] || client . new ( client_opts )
195
198
{ :dynamo_db_client => dynamo_db_client }
@@ -258,22 +261,5 @@ def symbolize_keys(options)
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 = [ :secret_access_key , :region , :access_key_id , :session_token ]
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
0 commit comments