-
Notifications
You must be signed in to change notification settings - Fork 106
Fix auth with GitHub #288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix auth with GitHub #288
Conversation
WalkthroughThe changes refactor the authentication logic for cloning Git repositories in the backend. The method responsible for obtaining credentials was renamed and its implementation reworked to immediately return credentials upon finding a valid token for supported providers (GitHub, GitLab, Gitea, Bitbucket). The logic now handles username and password assignment per provider requirements. In the repository synchronization process, the new credentials method is used, and a workaround is added to correctly format the clone URL when only a password is present, addressing issues with malformed URLs for GitHub tokens. Changes
Assessment against linked issues
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/backend/src/repoManager.ts
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (2)
packages/backend/src/repoManager.ts (2)
173-221
: Improved credential handling by provider typeThis refactored implementation correctly handles authentication credentials for different Git providers. The method now immediately returns upon finding valid credentials and properly formats username/password combinations according to each provider's requirements:
- GitHub and Gitea: only password (token)
- GitLab: username "oauth2" with password
- Bitbucket: configured username or default "x-token-auth" with password
The optional username in the return type signature is an important improvement that enables the URL handling fix later in the code.
251-265
: Fixed GitHub authentication with proper URL encodingThis change addresses the core issue with GitHub authentication by detecting when only a password is present and properly formatting the URL. The workaround correctly handles the edge case where URL.toString() would produce a malformed URL with an empty username followed by
:
(likehttps://:password@example.com
).This fix is essential because GitHub's API requires the token to be passed as the username when basic auth is used with personal access tokens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
CHANGELOG.md (1)
13-14
: Use imperative mood for the changelog bullet
For consistency with other entries under “### Fixes” (which use “Fix …” rather than “Fixes …”), update the bullet to start with “Fix”.Apply this diff:
- - Fixes regression introduced in v3.1.0 that causes auth errors with GitHub. [#288](https://github.com/sourcebot-dev/sourcebot/pull/288) + - Fix regression introduced in v3.1.0 that causes auth errors with GitHub. [#288](https://github.com/sourcebot-dev/sourcebot/pull/288)🧰 Tools
🪛 LanguageTool
[grammar] ~13-~13: Possible agreement error. You should probably use: “Fix Fixes” or “Fixes fix”.
Context: ...//pull/280) ### Fixes - Fixes regression introduced in v3.1.0 that ca...(AGREEMENT_SENT_START)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
CHANGELOG.md
(1 hunks)packages/backend/src/repoManager.ts
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/backend/src/repoManager.ts
🧰 Additional context used
🪛 LanguageTool
CHANGELOG.md
[grammar] ~13-~13: Possible agreement error. You should probably use: “Fix Fixes” or “Fixes fix”.
Context: ...//pull/280) ### Fixes - Fixes regression introduced in v3.1.0 that ca...
(AGREEMENT_SENT_START)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
This PR fixes a regression causing auth errors with GitHub. Also cleans up the code a bit for repo credential fetching.
Fixes #286
Summary by CodeRabbit
Bug Fixes
Documentation