diff options
author | José Valim <jose.valim@gmail.com> | 2011-11-09 20:11:46 -0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-11-09 20:21:52 -0200 |
commit | a625523e755421b0f96fe5b0a885462ef51582b1 (patch) | |
tree | 4d565b0e42f8ed8be5e08fc2c60fbc577e68fb47 /activesupport/lib/active_support | |
parent | 71e84a3b514b6a2630dfd7f658f4e7597424d6e3 (diff) | |
download | rails-a625523e755421b0f96fe5b0a885462ef51582b1.tar.gz rails-a625523e755421b0f96fe5b0a885462ef51582b1.tar.bz2 rails-a625523e755421b0f96fe5b0a885462ef51582b1.zip |
Don't marshal dump twice when using encryptor.
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/message_encryptor.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/message_encryptor.rb b/activesupport/lib/active_support/message_encryptor.rb index 5ab0cc83a7..9ef2b29580 100644 --- a/activesupport/lib/active_support/message_encryptor.rb +++ b/activesupport/lib/active_support/message_encryptor.rb @@ -10,6 +10,16 @@ module ActiveSupport # This can be used in situations similar to the <tt>MessageVerifier</tt>, but where you don't # want users to be able to determine the value of the payload. class MessageEncryptor + module NullSerializer #:nodoc: + def self.load(value) + value + end + + def self.dump(value) + value + end + end + class InvalidMessage < StandardError; end OpenSSLCipherError = OpenSSL::Cipher.const_defined?(:CipherError) ? OpenSSL::Cipher::CipherError : OpenSSL::CipherError @@ -21,6 +31,7 @@ module ActiveSupport @secret = secret @cipher = options[:cipher] || 'aes-256-cbc' + @verifier = MessageVerifier.new(@secret, :serializer => NullSerializer) @serializer = options[:serializer] || Marshal end @@ -86,7 +97,7 @@ module ActiveSupport end def verifier - MessageVerifier.new(@secret) + @verifier end end end |