Cognito logout fails with "Bad authority" behind reverse proxy#1888
Cognito logout fails with "Bad authority" behind reverse proxy#1888Respirayson wants to merge 1 commit into
Conversation
|
AI Summary The issue describes a Cognito logout failure with a "Bad authority" error when the application runs behind a reverse proxy with SSL termination. The problem arises because the old URL reconstruction logic incorrectly appended a port ( |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesCognito Logout URL Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Hi Respirayson! 👋
Welcome, and thank you for opening your first PR in the repo!
Please wait for triaging by our maintainers.
Please take a look at our contributing guide.
Issue: #1878
What changes did you make? (Give an overview)
What
Fixes a 500 error on logout (
InvalidUrlException: Bad authority) when kafbat-ui runs behind a reverse proxy with SSL termination (e.g. AWS ALB) and is configured with Cognito OAuth2 auth.Why
CognitoLogoutSuccessHandlerpreviously rebuilt the base redirect URL viaUrlUtils.buildFullRequestUrl(scheme, host, port, ...), manually passing the request's port. When no explicit port is present on the incoming request (common behind a proxy),URI.getPort()returns-1, and the old helper always appended:portregardless which produceshttps://host:-1/. Spring Framework 6.2'sRfcUriParserstrictly rejects this as an invalid authority.Fix
Replaced the manual URL reconstruction with
UriComponentsBuilder.fromUri(requestUri), which copies the URI's fields directly and correctly omits the port segment entirely when it's-1, instead of serializing it as:-1.Testing
Added
CognitoLogoutSuccessHandlerTestcovering:logout_uri.Is there anything you'd like reviewers to focus on?
How Has This Been Tested? (put an "x" (case-sensitive!) next to an item)
Checklist (put an "x" (case-sensitive!) next to all the items, otherwise the build will fail)
Check out Contributing and Code of Conduct
A picture of a cute animal (not mandatory but encouraged)

Summary by CodeRabbit
Bug Fixes
Tests