module ActionDispatch::Cookies::ChainedCookieJars
def encrypted
# => Set-Cookie: discount=DIQ7fw==--K3n//8vvnSbGq9dA--7Xh91HfLpwzbj1czhBiwOg==; path=/
cookies.encrypted[:discount] = 45
Example:
app's `secret_key_base`.
This jar requires that you set a suitable secret for the verification on your
cookies encrypted with HMAC AES-256-CBC will be transparently upgraded.
`config.action_dispatch.encrypted_signed_cookie_salt` are both set, legacy
If `config.action_dispatch.encrypted_cookie_salt` and
by the user (or a 3rd party), `nil` will be returned.
to the client and will decrypt them for read. If the cookie was tampered with
Returns a jar that'll automatically encrypt cookie values before sending them
def encrypted @encrypted ||= EncryptedKeyRotatingCookieJar.new(self) end
def encrypted_cookie_cipher
def encrypted_cookie_cipher request.encrypted_cookie_cipher || "aes-256-gcm" end
def permanent
cookies.permanent.signed[:remember_me] = current_user.id
permanent, signed cookies. Examples:
This jar allows chaining with the signed jar as well, so you can set
regular accessor.
This jar is only meant for writing. You'll read permanent cookies through the
# => Set-Cookie: prefers_open_id=true; path=/; expires=Sun, 16-Dec-2029 03:24:16 GMT
cookies.permanent[:prefers_open_id] = true
expiration date 20 years from now. Example:
Returns a jar that'll automatically set the assigned cookies to have an
def permanent @permanent ||= PermanentCookieJar.new(self) end
def prepare_upgrade_legacy_hmac_aes_cbc_cookies?
def prepare_upgrade_legacy_hmac_aes_cbc_cookies? request.secret_key_base.present? && request.authenticated_encrypted_cookie_salt.present? && !request.use_authenticated_cookie_encryption end
def signed
# => Set-Cookie: discount=BAhpMg==--2c1c6906c90a3bc4fd54a51ffb41dffa4bf6b5f7; path=/
cookies.signed[:discount] = 45
Example:
app's `secret_key_base`.
This jar requires that you set a suitable secret for the verification on your
returned.
signed cookie was tampered with by the user (or a 3rd party), `nil` will be
creating cookies with values that the user is not supposed to change. If a
value and verify it when reading from the cookie again. This is useful for
Returns a jar that'll automatically generate a signed representation of cookie
def signed @signed ||= SignedKeyRotatingCookieJar.new(self) end
def signed_cookie_digest
def signed_cookie_digest request.signed_cookie_digest || "SHA1" end
def signed_or_encrypted
`secret_key_base` is set. Used by ActionDispatch::Session::CookieStore to
Returns the `signed` or `encrypted` jar, preferring `encrypted` if
def signed_or_encrypted @signed_or_encrypted ||= if request.secret_key_base.present? encrypted else signed end end
def upgrade_legacy_hmac_aes_cbc_cookies?
def upgrade_legacy_hmac_aes_cbc_cookies? request.secret_key_base.present? && request.encrypted_signed_cookie_salt.present? && request.encrypted_cookie_salt.present? && request.use_authenticated_cookie_encryption end