Update cookie.rb to support allow old HMAC generation#55
Open
Update cookie.rb to support allow old HMAC generation#55
Conversation
I could be wrong, but I think that https://github.com/rack/rack/pull/1177/files is not backward compatible. It still allows to verify old sessions cookies with the `--$HMAC` format when using a set of a legacy options, but it doesn't allow to create cookies sessions with the old `--$HMAC` format, even with `legacy_generate_hmac` and `legacy_hmac_secret` are set. Comment in the code mentions this is backward compatible with the correct options, but still ``` if @Secrets.first session_data << "--#{generate_hmac(session_data, @Secrets.first)}" end ``` is removed and I don't see any other place where the `--$HMAC` could be set. This is adding it back.
|
Should we add a test for this case? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello,
I'm working on upgrading an old codebase that relies on the legacy session cookie format (with the
--$HMACsuffix).I noticed that after https://github.com/rack/rack/pull/1177/files (PR is not merged in
rack/rack, but the code was merged manually in this repository based on this comment), the verification of old session cookies in this format is still supported when legacy options are set but new session cookies are no longer created with the--$HMACsuffix, even iflegacy_generate_hmacandlegacy_hmac_secretare provided.The code comments suggest that backward compatibility should be maintained:
However, the code that previously appended the HMAC to new cookies appears to have been removed:
I couldn't find any other place where the
--$HMACsuffix is added for new cookies.Would you consider restoring this behavior when
legacy_hmac_secretis set?I'm happy to update / add tests if this is acceptable, but I wanted to get an opinion first as I'm not familiar with this codebase and could be wrong here :)
Thanks a lot !