Fix: Multi-Cookie Session Authentication Failure#5348
Open
gazzadownunder wants to merge 2 commits intoobot-platform:mainfrom
Open
Fix: Multi-Cookie Session Authentication Failure#5348gazzadownunder wants to merge 2 commits intoobot-platform:mainfrom
gazzadownunder wants to merge 2 commits intoobot-platform:mainfrom
Conversation
When OAuth sessions exceed 4KB (typically from auth providers with many roles/groups), oauth2-proxy splits the session across multiple cookies named obot_access_token_0, obot_access_token_1, etc. In this mode, the base cookie "obot_access_token" does NOT exist. The AuthenticateRequest function only checked for the base cookie name, causing authentication to fail for large sessions even though valid session cookies were present. This resulted in users being redirected back to the login page in an infinite loop. This fix checks for both the base cookie (obot_access_token) and the first multi-cookie (obot_access_token_0), allowing authentication to succeed for both normal and multi-cookie sessions. Impact: - Fixes infinite login loop for users with large OAuth sessions - Particularly affects Keycloak deployments with many roles/groups - No impact on normal (<4KB) sessions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Contributor
|
@njhale @g-linville review this when you have a chance. I know it's older, but it might not be a bad thing to get in. |
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.
Issue: Multi-Cookie Session Authentication Failure #5347
Root Cause
File: pkg/proxy/proxy.go:54
When OAuth sessions exceed 4KB, oauth2-proxy automatically splits the session across multiple cookies:
Cookie names: obot_access_token_0, obot_access_token_1, obot_access_token_2, etc.
The base cookie obot_access_token does NOT exist in multi-cookie mode
The AuthenticateRequest() function only checks for the base cookie name:
When the base cookie doesn't exist:
Solution
Check for both the base cookie and the first multi-cookie: