mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 04:18:05 +00:00
fix(cliproxy): use management oauth-callback in paste flow
This commit is contained in:
@@ -258,6 +258,10 @@ export function getManagementAuthUrlPath(provider: CLIProxyProvider): string {
|
||||
return `/v0/management/${authUrlProvider}-auth-url?is_webui=true`;
|
||||
}
|
||||
|
||||
export function getManagementOAuthCallbackPath(): string {
|
||||
return '/v0/management/oauth-callback';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OAuth config for provider
|
||||
*/
|
||||
|
||||
@@ -38,6 +38,7 @@ import {
|
||||
ProviderOAuthConfig,
|
||||
CLIPROXY_CALLBACK_PROVIDER_MAP,
|
||||
getManagementAuthUrlPath,
|
||||
getManagementOAuthCallbackPath,
|
||||
normalizeKiroAuthMethod,
|
||||
} from './auth-types';
|
||||
import { isHeadlessEnvironment, killProcessOnPort, showStep } from './environment-detector';
|
||||
@@ -370,8 +371,7 @@ async function handlePasteCallbackMode(
|
||||
|
||||
const callbackProvider = CLIPROXY_CALLBACK_PROVIDER_MAP[provider] || provider;
|
||||
|
||||
// Note: /oauth-callback is a CLIProxyAPI endpoint (not /v0/management prefix)
|
||||
const callbackResponse = await fetch(buildProxyUrl(target, '/oauth-callback'), {
|
||||
const callbackResponse = await fetch(buildProxyUrl(target, getManagementOAuthCallbackPath()), {
|
||||
method: 'POST',
|
||||
headers: buildManagementHeaders(target, { 'Content-Type': 'application/json' }),
|
||||
body: JSON.stringify({
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
import { getManagementAuthUrlPath } from '../../../src/cliproxy/auth/auth-types';
|
||||
import {
|
||||
getManagementAuthUrlPath,
|
||||
getManagementOAuthCallbackPath,
|
||||
} from '../../../src/cliproxy/auth/auth-types';
|
||||
|
||||
describe('auth-types management auth-url path', () => {
|
||||
it('maps providers to CLIProxyAPI management auth-url routes', () => {
|
||||
@@ -16,4 +19,8 @@ describe('auth-types management auth-url path', () => {
|
||||
expect(getManagementAuthUrlPath('ghcp')).toBe('/v0/management/github-auth-url?is_webui=true');
|
||||
expect(getManagementAuthUrlPath('kiro')).toBe('/v0/management/kiro-auth-url?is_webui=true');
|
||||
});
|
||||
|
||||
it('uses CLIProxyAPI management oauth-callback route', () => {
|
||||
expect(getManagementOAuthCallbackPath()).toBe('/v0/management/oauth-callback');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user