File tree 3 files changed +20
-1
lines changed
3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -252,6 +252,7 @@ def initialize(app, options = {})
252
252
@default_options = self . class ::DEFAULT_OPTIONS . merge ( options )
253
253
@key = @default_options . delete ( :key )
254
254
@cookie_only = @default_options . delete ( :cookie_only )
255
+ @same_site = @default_options . delete ( :same_site )
255
256
initialize_sid
256
257
end
257
258
Original file line number Diff line number Diff line change @@ -118,7 +118,6 @@ def initialize(app, options = {})
118
118
Called from: #{ caller [ 0 ] } .
119
119
MSG
120
120
@coder = options [ :coder ] ||= Base64 ::Marshal . new
121
- @same_site = options . delete :same_site
122
121
super ( app , options . merge! ( cookie_only : true ) )
123
122
end
124
123
Original file line number Diff line number Diff line change 178
178
pool . pool [ session_id . public_id ] . must_be_nil
179
179
end
180
180
181
+ it "passes through same_site option to session pool" do
182
+ pool = Rack ::Session ::Pool . new ( incrementor , same_site : :none )
183
+ req = Rack ::MockRequest . new ( pool )
184
+ res = req . get ( "/" )
185
+ res [ "Set-Cookie" ] . must_include "SameSite=None"
186
+ end
187
+
188
+ it "allows using a lambda to specify same_site option, because some browsers require different settings" do
189
+ pool = Rack ::Session ::Pool . new ( incrementor , same_site : lambda { |req , res | :none } )
190
+ req = Rack ::MockRequest . new ( pool )
191
+ res = req . get ( "/" )
192
+ res [ "Set-Cookie" ] . must_include "SameSite=None"
193
+
194
+ pool = Rack ::Session ::Pool . new ( incrementor , same_site : lambda { |req , res | :lax } )
195
+ req = Rack ::MockRequest . new ( pool )
196
+ res = req . get ( "/" )
197
+ res [ "Set-Cookie" ] . must_include "SameSite=Lax"
198
+ end
199
+
181
200
# anyone know how to do this better?
182
201
it "should merge sessions when multithreaded" do
183
202
unless $DEBUG
You can’t perform that action at this time.
0 commit comments