mirror of
https://github.com/tiennm99/ccs.git
synced 2026-08-07 04:23:41 +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`;
|
return `/v0/management/${authUrlProvider}-auth-url?is_webui=true`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getManagementOAuthCallbackPath(): string {
|
||||||
|
return '/v0/management/oauth-callback';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get OAuth config for provider
|
* Get OAuth config for provider
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import {
|
|||||||
ProviderOAuthConfig,
|
ProviderOAuthConfig,
|
||||||
CLIPROXY_CALLBACK_PROVIDER_MAP,
|
CLIPROXY_CALLBACK_PROVIDER_MAP,
|
||||||
getManagementAuthUrlPath,
|
getManagementAuthUrlPath,
|
||||||
|
getManagementOAuthCallbackPath,
|
||||||
normalizeKiroAuthMethod,
|
normalizeKiroAuthMethod,
|
||||||
} from './auth-types';
|
} from './auth-types';
|
||||||
import { isHeadlessEnvironment, killProcessOnPort, showStep } from './environment-detector';
|
import { isHeadlessEnvironment, killProcessOnPort, showStep } from './environment-detector';
|
||||||
@@ -370,8 +371,7 @@ async function handlePasteCallbackMode(
|
|||||||
|
|
||||||
const callbackProvider = CLIPROXY_CALLBACK_PROVIDER_MAP[provider] || provider;
|
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, getManagementOAuthCallbackPath()), {
|
||||||
const callbackResponse = await fetch(buildProxyUrl(target, '/oauth-callback'), {
|
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: buildManagementHeaders(target, { 'Content-Type': 'application/json' }),
|
headers: buildManagementHeaders(target, { 'Content-Type': 'application/json' }),
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import { describe, expect, it } from 'bun:test';
|
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', () => {
|
describe('auth-types management auth-url path', () => {
|
||||||
it('maps providers to CLIProxyAPI management auth-url routes', () => {
|
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('ghcp')).toBe('/v0/management/github-auth-url?is_webui=true');
|
||||||
expect(getManagementAuthUrlPath('kiro')).toBe('/v0/management/kiro-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