Class: ActionDispatch::Cookies::EncryptedKeyRotatingCookieJar
- Inherits:
-
AbstractCookieJar
- Object
- AbstractCookieJar
- ActionDispatch::Cookies::EncryptedKeyRotatingCookieJar
- Includes:
- SerializedCookieJars
- Defined in:
- lib/action_dispatch/middleware/cookies.rb
Overview
:nodoc:
Constant Summary
Constants included from SerializedCookieJars
SerializedCookieJars::SERIALIZER
Instance Method Summary collapse
-
#initialize(parent_jar) ⇒ EncryptedKeyRotatingCookieJar
constructor
A new instance of EncryptedKeyRotatingCookieJar.
Methods inherited from AbstractCookieJar
Methods included from ChainedCookieJars
#encrypted, #permanent, #signed, #signed_or_encrypted
Constructor Details
#initialize(parent_jar) ⇒ EncryptedKeyRotatingCookieJar
Returns a new instance of EncryptedKeyRotatingCookieJar.
634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
# File 'lib/action_dispatch/middleware/cookies.rb', line 634 def initialize(parent_jar) super if request. key_len = ActiveSupport::MessageEncryptor.key_len() secret = request.key_generator.generate_key(request., key_len) @encryptor = ActiveSupport::MessageEncryptor.new(secret, cipher: , serializer: SERIALIZER) else key_len = ActiveSupport::MessageEncryptor.key_len("aes-256-cbc") secret = request.key_generator.generate_key(request., key_len) sign_secret = request.key_generator.generate_key(request.) @encryptor = ActiveSupport::MessageEncryptor.new(secret, sign_secret, cipher: "aes-256-cbc", serializer: SERIALIZER) end request..encrypted.each do |(*secrets)| = secrets. @encryptor.rotate(*secrets, serializer: SERIALIZER, **) end if legacy_cipher = "aes-256-cbc" secret = request.key_generator.generate_key(request., ActiveSupport::MessageEncryptor.key_len(legacy_cipher)) sign_secret = request.key_generator.generate_key(request.) @encryptor.rotate(secret, sign_secret, cipher: legacy_cipher, digest: digest, serializer: SERIALIZER) elsif future_cipher = secret = request.key_generator.generate_key(request., ActiveSupport::MessageEncryptor.key_len(future_cipher)) @encryptor.rotate(secret, nil, cipher: future_cipher, serializer: SERIALIZER) end end |