authenticate icon indicating copy to clipboard operation
authenticate copied to clipboard

Added functionality for signed and encrypted cookies

Open yumitsu opened this issue 7 years ago • 3 comments

Good day. I found that Authenticate doesn't support signed and encrypted cookies yet, so I decided to implement it. I will be glad if you'll accept PR and maybe even bump gem version. Thanks.

yumitsu avatar Jan 24 '18 06:01 yumitsu

Hello @yumitsu, thanks for the contribution, this is a great start!

I'm still reading through the PR and considering the change. I do see one potential issue that probably needs some refinement. Authenticate Configuration options are provided for both encrypted and signed cookies, but Session#get_cookies_class defers to @cookies.signed_or_encrypted if either Configuration#signed_cookie or Configuration#encrypted_cookie is true. But signed_or_encrypted will always call encrypted if the secret key base is present.

I believe this means that both Authenticate configuration options, Authenticate.configuration.signed and Authenticate.configuration.encrypted, will result in an encrypted cookie being generated if the app's secret key base is preset, or a signed cookie being generated if the secret key base is not present.

I think the solution is for Session (or it's delegate) to avoid calling the cookie_jar.signed_or_encrypted, and instead have Session call either cookie_jar.encrypted or cookie_jar.signed depending on the configuration and presence of the secret key base in the request.

tomichj avatar Feb 21 '18 02:02 tomichj

@tomichj Thanks for your review. Yes, I agree with you, this PR need some changes.

yumitsu avatar Feb 26 '18 15:02 yumitsu

@tomichj Please look at new changes. Thanks!

yumitsu avatar Feb 28 '18 00:02 yumitsu