allow disabling session_secret
This commit is contained in:
parent
652411f832
commit
13b79de10c
|
@ -1296,7 +1296,8 @@ module Sinatra
|
||||||
|
|
||||||
def setup_sessions(builder)
|
def setup_sessions(builder)
|
||||||
return unless sessions?
|
return unless sessions?
|
||||||
options = { :secret => session_secret }
|
options = {}
|
||||||
|
options[:secret] = session_secret if session_secret?
|
||||||
options.merge! sessions.to_hash if sessions.respond_to? :to_hash
|
options.merge! sessions.to_hash if sessions.respond_to? :to_hash
|
||||||
builder.use Rack::Session::Cookie, options
|
builder.use Rack::Session::Cookie, options
|
||||||
end
|
end
|
||||||
|
|
|
@ -313,6 +313,20 @@ class HelpersTest < Test::Unit::TestCase
|
||||||
assert_body 'ok'
|
assert_body 'ok'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'allows disabling session secret' do
|
||||||
|
mock_app do
|
||||||
|
enable :sessions
|
||||||
|
disable :session_secret
|
||||||
|
get '/' do
|
||||||
|
assert !env['rack.session.options'].include?(:session_secret)
|
||||||
|
'ok'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
get '/'
|
||||||
|
assert_body 'ok'
|
||||||
|
end
|
||||||
|
|
||||||
it 'accepts an options hash' do
|
it 'accepts an options hash' do
|
||||||
mock_app do
|
mock_app do
|
||||||
set :sessions, :foo => :bar
|
set :sessions, :foo => :bar
|
||||||
|
|
Loading…
Reference in New Issue