Skip to content

refactor(integrations): unify OAuth integration routes#3379

Open
RSO wants to merge 18 commits into
mainfrom
amethyst-motion
Open

refactor(integrations): unify OAuth integration routes#3379
RSO wants to merge 18 commits into
mainfrom
amethyst-motion

Conversation

@RSO
Copy link
Copy Markdown
Contributor

@RSO RSO commented May 21, 2026

Summary

  • Unified standard OAuth integrations behind dynamic /api/integrations/[platform]/connect and /api/integrations/[platform]/callback routes while keeping GitHub App and Google OAuth on their special routes.
  • Replaced Slack/Linear/Discord getOAuthUrl tRPC initiation with shared connect paths, and unified user/org platform detail pages behind shared dynamic UI.
  • Preserved OAuth resume behavior, including sign-in callback allowlisting, returnTo redirects, encoded callback errors, and self-hosted GitLab credential handling via an authenticated POST/Redis handoff instead of query-string secrets.

Verification

  • Not manually verified in browser; OAuth provider flows require external app credentials and callback setup.

Visual Changes

N/A

Reviewer Notes

  • Review the OAuth redirect and returnTo paths closely, especially unauthenticated connect resumes and platform-specific success/error query parameters.
  • GitLab self-hosted OAuth uses POST for clientSecret handoff; the GET connect route intentionally no longer consumes clientSecret.

Comment thread apps/web/src/lib/integrations/oauth/platforms/gitlab-connect.ts Outdated
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented May 21, 2026

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

A dead clientSecret check in handleGitLabOAuthConnect's GET handler makes the sign-in resume callback path unreachable; the previous stale-JSDoc warning was resolved in commit 6cf03bfee.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/integrations/oauth/platforms/gitlab-connect.ts 58 Dead condition — searchParams.has('clientSecret') can never be true in the GET handler; the buildGitLabDetailCallbackPath branch is unreachable dead code
Resolved Issues
  • gitlab-connect.ts JSDoc listing clientId/clientSecret as GET query params — fixed in 6cf03bfee
Incremental changes reviewed (4 new commits)
  • 1f2d5df — merge main into branch — no new issues
  • 658246569 — merge main into branch — no new issues
  • cdf5b3e00 — merge main into branch — no new issues
  • 6cf03bfeedocs(integrations): clarify GitLab OAuth credentials — fixes previous JSDoc warning; exposes pre-existing dead clientSecret check at line 58
Files Reviewed (49 files)
  • apps/web/src/lib/integrations/oauth/platforms/gitlab-connect.ts — 1 warning (line 58, dead clientSecret condition)
  • apps/web/src/lib/integrations/oauth/routes.ts — no issues
  • apps/web/src/components/integrations/IntegrationDetailPage.tsx — no issues
  • apps/web/src/app/api/integrations/linear/connect/route.test.ts — no issues
  • apps/web/src/lib/integrations/oauth/common.ts — no issues
  • (all other previously-reviewed files — unchanged, no issues)

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-4.6 · 1,274,989 tokens

Review guidance: REVIEW.md from base branch main

if (authFailedResponse) {
return redirectToSignInForOAuthConnect(
request,
request.nextUrl.searchParams.has('clientSecret')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Dead condition — clientSecret is never present in GET query params

The GET handler no longer reads clientSecret from the URL (it was moved to POST-only). This .has('clientSecret') check can never be true, so redirectToSignInForOAuthConnect always receives undefined as its second argument. The branch that resolves to buildGitLabDetailCallbackPath(organizationId) is unreachable dead code.

Either remove the ternary and pass undefined directly, or, if the intent is to restore the self-hosted GitLab sign-in resume behaviour (redirect back to the detail page after sign-in), derive the callback path from instanceUrl or the organizationId that is already read from the query string.

? await getDefaultAllowedModel(owner.id, SLACK_DEFAULT_MODEL)
: SLACK_DEFAULT_MODEL;
? await getDefaultAllowedModel(owner.id, DEFAULT_BOT_MODEL)
: DEFAULT_BOT_MODEL;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this Slack default model change intended? New personal Slack installations now default to kilo-auto/frontier through DEFAULT_BOT_MODEL instead of the previous kilo-auto/free, which can change credit/cost behavior for Slack bot usage.

@@ -150,19 +147,9 @@ export function SlackIntegrationDetails({
}
}, [success, error]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the removed getOAuthUrl tRPC procedures stay as compatibility shims for one deploy? Existing pages loaded before this rollout still call them when the user clicks Connect/Re-install; this new redirect path only helps freshly loaded clients.

const instanceUrl = searchParams.get('instanceUrl') || undefined;
const returnToParam = searchParams.get('returnTo') || undefined;
const returnTo = returnToParam ? validateReturnPath(returnToParam) : null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this path keep a short-lived compatibility branch for authenticated GETs with clientId/clientSecret? Old client bundles still send self-hosted GitLab OAuth credentials as query params, and this now drops them before building the OAuth URL, so those starts fail with oauth_init_failed during rollout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants