What exactly does SignedCookieJar do?
And what is the difference from that and using MessageEncryptor.encrypt_and_sign on the cookie value?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re ever looking for exactly what a given class does, I’d recommend consulting the source.
SignedCookieJar, for instance, is inrails/actionpack/lib/action_dispatch/middleware/cookies.rb.It would seem that a
SignedCookieJaris a wrapper around the standard cookie jar, but before setting a cookie to its parent jar it will sign it with anActiveSupport::MessageVerifier‘sgeneratemethod, and upon getting a cookie from the parent jar it will returnnilif the verifier’sverifymethod invalidates the signature.The difference seems to be that
MessageVerifieronly signs data but leaves the original data intact, whereasMessageEncryptorwill additionally encrypt the data before signing it. The Rails docs say that the use case is different in that:For signed cookies, we’re usually not too worried about that.