diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2015-09-06 17:46:18 +0200 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2015-09-08 20:27:04 +0200 |
commit | b807ac7a7a195df663bbc9dfba87d397936b50f0 (patch) | |
tree | 04a28dbad82443c72cc57ee453c921d2a2830fa5 /actionpack | |
parent | 379ddf54c00723c816b0dd4aa78d0cd47f159772 (diff) | |
download | rails-b807ac7a7a195df663bbc9dfba87d397936b50f0.tar.gz rails-b807ac7a7a195df663bbc9dfba87d397936b50f0.tar.bz2 rails-b807ac7a7a195df663bbc9dfba87d397936b50f0.zip |
Use commit in the SignedCookieJar
Lets us avoid worrying about parsing the options and doing just what we need.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/cookies.rb | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb index 4a9b534212..bbfd46e891 100644 --- a/actionpack/lib/action_dispatch/middleware/cookies.rb +++ b/actionpack/lib/action_dispatch/middleware/cookies.rb @@ -496,12 +496,11 @@ module ActionDispatch end end - class SignedCookieJar #:nodoc: - include ChainedCookieJars + class SignedCookieJar < AbstractCookieJar # :nodoc: include SerializedCookieJars def initialize(parent_jar) - @parent_jar = parent_jar + super secret = key_generator.generate_key(request.signed_cookie_salt) @verifier = ActiveSupport::MessageVerifier.new(secret, digest: digest, serializer: ActiveSupport::MessageEncryptor::NullSerializer) end @@ -514,21 +513,13 @@ module ActionDispatch end end - # Signs and sets the cookie named +name+. The second argument may be the cookie's - # value or a hash of options as documented above. - def []=(name, options) - if options.is_a?(Hash) - options.symbolize_keys! + private + def commit(options) options[:value] = @verifier.generate(serialize(options[:value])) - else - options = { :value => @verifier.generate(serialize(options)) } - end - raise CookieOverflow if options[:value].bytesize > MAX_COOKIE_SIZE - @parent_jar[name] = options - end + raise CookieOverflow if options[:value].bytesize > MAX_COOKIE_SIZE + end - private def verify(signed_message) @verifier.verify(signed_message) rescue ActiveSupport::MessageVerifier::InvalidSignature |