fix: frequent logout issues -- improve cookie security attributes and URL preservation #66
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.
This PR addresses the frequent logout issues reported in #58 by fixing two key problems with cookie handling and OAuth redirect flow.
Issues Fixed
1. Missing Cookie Security Attributes
The JWT cookie was only setting basic attributes (
Name,Value,HttpOnly,Expires), missing several critical security attributes that could cause browsers to reject or not properly persist cookies in complex deployment scenarios.Before:
After:
2. Lost Query Parameters in OAuth Redirects
The
getRawRequestUrlfunction was not preserving query parameters during OAuth redirects, causing users to lose context when re-authentication was required.Before:
After:
Why These Changes Fix Frequent Logouts
Browser Compatibility: The added cookie attributes (
Path,SameSite,Secure) ensure cookies are properly handled by modern browsers in:Load Balancer Resilience: Enhanced cookie attributes improve compatibility with complex deployment scenarios involving multiple Traefik pods behind load balancers
User Experience: Preserving query parameters means users maintain their intended destination and context during re-authentication flows
Testing
Added comprehensive tests covering:
All existing tests continue to pass, ensuring backward compatibility.
Impact
This should significantly reduce the frequent logout issues experienced in multi-pod Traefik deployments.
Fixes #58.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.