aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-03-06 04:09:14 +0000
committerRick Olson <technoweenie@gmail.com>2007-03-06 04:09:14 +0000
commit2b7dbad8e081b1ce84a7262b1b0953254bf8f651 (patch)
tree63f7a2ec758a362736f1805be0f223ade6a573b9
parentd1b08f4a751f12fbe32ccf7a31cc905656a344ff (diff)
downloadrails-2b7dbad8e081b1ce84a7262b1b0953254bf8f651.tar.gz
rails-2b7dbad8e081b1ce84a7262b1b0953254bf8f651.tar.bz2
rails-2b7dbad8e081b1ce84a7262b1b0953254bf8f651.zip
Add a #dbman attr_reader for CGI::Session and make CGI::Session::CookieStore#generate_digest public so it's easy to generate digests
using the cookie store's secret. [Rick] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6342 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--actionpack/CHANGELOG3
-rw-r--r--actionpack/lib/action_controller/cgi_ext/session_performance_fix.rb1
-rw-r--r--actionpack/lib/action_controller/session/cookie_store.rb12
3 files changed, 10 insertions, 6 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 05ed1a5038..ce27a28188 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,8 @@
*SVN*
+# Add a #dbman attr_reader for CGI::Session and make CGI::Session::CookieStore#generate_digest public so it's easy to generate digests
+using the cookie store's secret. [Rick]
+
* Added Request#url that returns the complete URL used for the request [DHH]
* Extract dynamic scaffolding into a plugin. #7700 [Josh Peek]
diff --git a/actionpack/lib/action_controller/cgi_ext/session_performance_fix.rb b/actionpack/lib/action_controller/cgi_ext/session_performance_fix.rb
index 6f9a09da6d..d3dc643d3f 100644
--- a/actionpack/lib/action_controller/cgi_ext/session_performance_fix.rb
+++ b/actionpack/lib/action_controller/cgi_ext/session_performance_fix.rb
@@ -26,6 +26,7 @@ class CGI
# Make the CGI instance available to session stores.
attr_reader :cgi
+ attr_reader :dbman
alias_method :initialize_without_cgi_reader, :initialize
def initialize(cgi, options = {})
@cgi = cgi
diff --git a/actionpack/lib/action_controller/session/cookie_store.rb b/actionpack/lib/action_controller/session/cookie_store.rb
index d232dd448c..fe2d96e17d 100644
--- a/actionpack/lib/action_controller/session/cookie_store.rb
+++ b/actionpack/lib/action_controller/session/cookie_store.rb
@@ -94,6 +94,12 @@ class CGI::Session::CookieStore
write_cookie('value' => '', 'expires' => 1.year.ago)
end
+ # Generate the HMAC keyed message digest. Uses SHA1 by default.
+ def generate_digest(data)
+ key = @secret.respond_to?(:call) ? @secret.call(@session) : @secret
+ OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new(@digest), key, data)
+ end
+
private
# Marshal a session hash into safe cookie data. Include an integrity hash.
def marshal(session)
@@ -113,12 +119,6 @@ class CGI::Session::CookieStore
end
end
- # Generate the HMAC keyed message digest. Uses SHA1 by default.
- def generate_digest(data)
- key = @secret.respond_to?(:call) ? @secret.call(@session) : @secret
- OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new(@digest), key, data)
- end
-
# Read the session data cookie.
def read_cookie
@session.cgi.cookies[@cookie_options['name']].first