Conversation
This commit fixes two related session cookie issues: 1. Issue markbates#626: Duplicate Set-Cookie headers - CompleteUserAuth was calling StoreInSession before the deferred Logout - This caused two Set-Cookie headers: one valid, one expired (1970) - The browser received both, with the expired one overriding the valid one - Fix: Remove the unnecessary StoreInSession call since Logout clears the session anyway 2. Issue markbates#549: "securecookie: hash key is not set" after dependency upgrade - Upgraded gorilla/sessions v1.1.1 → v1.4.0 - Upgraded gorilla/securecookie v1.1.1 → v1.1.2 - The newer securecookie properly validates hash keys instead of silently failing - Error propagation was already working correctly Tests added: - Test_CompleteUserAuth_SingleSetCookie: Verifies only one Set-Cookie header - Test_StoreInSession_ReturnsErrorOnSaveFailure: Verifies error propagation - Test_GetAuthURL_PropagatesSessionErrors: Verifies end-to-end error handling Fixes markbates#626 Fixes markbates#549
WalkthroughThe PR updates gorilla/sessions and securecookie dependencies, removes redundant session storage from CompleteUserAuth to prevent duplicate Set-Cookie headers during OAuth flow completion, and adds tests verifying error handling and single Set-Cookie header emission. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
🧰 Additional context used🧬 Code graph analysis (1)gothic/gothic_test.go (2)
🪛 ast-grep (0.40.3)gothic/gothic_test.go[warning] 363-363: A secret is hard-coded in the application. Secrets stored in source code, such as credentials, identifiers, and other types of sensitive data, can be leaked and used by internal or external malicious actors. It is recommended to rotate the secret and retrieve them from a secure secret vault or Hardware Security Module (HSM), alternatively environment variables can be used if allowed by your company policy. (gorilla-cookie-store-hardcoded-session-key-go) 🔇 Additional comments (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Summary of ChangesHello @tphakala, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the stability and correctness of session cookie handling within the application. It resolves two critical upstream issues: one that caused immediate session invalidation due to duplicate Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively resolves two session cookie issues by upgrading dependencies and removing a redundant session storage call. The changes are logical and well-justified. Upgrading gorilla/sessions and gorilla/securecookie addresses an error related to unset hash keys, while removing the StoreInSession call in CompleteUserAuth correctly prevents the issuance of duplicate Set-Cookie headers. The addition of new regression tests is a great improvement, as they validate both fixes, including proper error propagation from session save operations and ensuring only a single logout cookie is set upon completion of user authentication. The changes are sound and the test coverage for them is thorough.
Summary
This PR fixes two related session cookie issues from upstream:
Set-Cookieheaders causing session to be immediately invalidatedChanges
Removed unnecessary
StoreInSessioncall inCompleteUserAuthSet-Cookieheaders (one valid, one expired)Upgraded dependencies
github.com/gorilla/sessionsv1.1.1 → v1.4.0github.com/gorilla/securecookiev1.1.1 → v1.1.2Added tests for regression prevention
Note
Also submitted as upstream PR: markbates#631
If upstream doesn't merge, this fork will have the fix.
Summary by CodeRabbit
Bug Fixes
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.