Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow to generate a sid using another secure random provider

  • Loading branch information...
commit 585d88daed7d62752b7b64e3140f64006c830c71 1 parent ccfdaf3
Santiago Pastorino spastorino authored
2  lib/rack/session/abstract/id.rb
View
@@ -229,7 +229,7 @@ def initialize_sid
def generate_sid(secure = @sid_secure)
if secure
- SecureRandom.hex(@sid_length)
+ secure.hex(@sid_length)
else
"%0#{@sid_length}x" % Kernel.rand(2**@sidbits - 1)
end
12 test/spec_session_abstract_id.rb
View
@@ -40,4 +40,14 @@ def reload_id
end
end
-end
+ should "allow to use another securerandom provider" do
+ secure_random = Class.new do
+ def hex(*args)
+ 'fake_hex'
+ end
+ end
+ id = Rack::Session::Abstract::ID.new nil, :secure_random => secure_random.new
+ id.send(:generate_sid).should.eql 'fake_hex'
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.