Class: ActionDispatch::Cookies::EncryptedCookieJar

Inherits:
AbstractCookieJar show all
Includes:
SerializedCookieJars
Defined in:
lib/action_dispatch/middleware/cookies.rb

Overview

:nodoc:

Direct Known Subclasses

UpgradeLegacyEncryptedCookieJar

Constant Summary

Constants included from SerializedCookieJars

SerializedCookieJars::MARSHAL_SIGNATURE

Instance Method Summary collapse

Methods inherited from AbstractCookieJar

#[], #[]=

Methods included from ChainedCookieJars

#encrypted, #permanent, #signed, #signed_or_encrypted

Constructor Details

#initialize(parent_jar) ⇒ EncryptedCookieJar

Returns a new instance of EncryptedCookieJar.



571
572
573
574
575
576
577
578
579
580
581
582
# File 'lib/action_dispatch/middleware/cookies.rb', line 571

def initialize(parent_jar)
  super

  if ActiveSupport::LegacyKeyGenerator === key_generator
    raise "You didn't set secrets.secret_key_base, which is required for this cookie jar. " +
      "Read the upgrade documentation to learn more about this new config option."
  end

  secret = key_generator.generate_key(request.encrypted_cookie_salt || "")[0, ActiveSupport::MessageEncryptor.key_len]
  sign_secret = key_generator.generate_key(request.encrypted_signed_cookie_salt || "")
  @encryptor = ActiveSupport::MessageEncryptor.new(secret, sign_secret, digest: digest, serializer: ActiveSupport::MessageEncryptor::NullSerializer)
end