Class: ActionDispatch::Cookies::SignedCookieJar
- Inherits:
-
Object
- Object
- ActionDispatch::Cookies::SignedCookieJar
- Includes:
- ChainedCookieJars, SerializedCookieJars
- Defined in:
- lib/action_dispatch/middleware/cookies.rb
Overview
:nodoc:
Direct Known Subclasses
Constant Summary
Constants included from SerializedCookieJars
ActionDispatch::Cookies::SerializedCookieJars::MARSHAL_SIGNATURE
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, options) ⇒ Object
-
#initialize(parent_jar, key_generator, options = {}) ⇒ SignedCookieJar
constructor
A new instance of SignedCookieJar.
Methods included from ChainedCookieJars
#encrypted, #permanent, #signed, #signed_or_encrypted
Constructor Details
#initialize(parent_jar, key_generator, options = {}) ⇒ SignedCookieJar
Returns a new instance of SignedCookieJar.
450 451 452 453 454 455 |
# File 'lib/action_dispatch/middleware/cookies.rb', line 450 def initialize(parent_jar, key_generator, = {}) @parent_jar = parent_jar @options = secret = key_generator.generate_key(@options[:signed_cookie_salt]) @verifier = ActiveSupport::MessageVerifier.new(secret, digest: digest, serializer: ActiveSupport::MessageEncryptor::NullSerializer) end |
Instance Method Details
#[](name) ⇒ Object
457 458 459 460 461 |
# File 'lib/action_dispatch/middleware/cookies.rb', line 457 def [](name) if = @parent_jar[name] deserialize name, verify() end end |
#[]=(name, options) ⇒ Object
463 464 465 466 467 468 469 470 471 472 473 |
# File 'lib/action_dispatch/middleware/cookies.rb', line 463 def []=(name, ) if .is_a?(Hash) .symbolize_keys! [:value] = @verifier.generate(serialize(name, [:value])) else = { :value => @verifier.generate(serialize(name, )) } end raise CookieOverflow if [:value].bytesize > MAX_COOKIE_SIZE @parent_jar[name] = end |