🐛 Fix inverted sendWithoutRequest predicate in HttpClient#53
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe PR inverts the bearer authentication predicate in HTTP client initialization. The ChangesBearer Auth Unauthorized Endpoint Predicate
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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.
Code Review
This pull request modifies the HttpClient configuration by flipping the logic for sending authentication tokens; it now avoids sending tokens only for endpoints not present in the unauthorizedEndpoints list. A critical security concern was raised regarding potential token leakage to external domains, as the current implementation lacks host verification. The reviewer suggested a more robust predicate that includes host validation and path normalization to mitigate this risk.
The predicate was sending the bearer token to login/registration and skipping preemptive sending everywhere else. Flipped to .none(...) so the token is attached to authenticated endpoints, not to the auth ones.
fd7a652 to
ed8ffef
Compare
sendWithoutRequestin Ktor returnstrueto attach the bearer token preemptively — the canonical example from the docs isrequest.url.host == "www.googleapis.com", i.e. returntruefor hosts where you want the token.The block in
HttpClient.ktreturnedtrueforunauthorizedEndpoints, which inverts the intent:/api/auth/loginand/api/auth/registrationFlipped
.any→.noneso the token is attached to authenticated endpoints and skipped for the auth ones, matching the variable name.Summary by CodeRabbit