Skip to content

Commit

Permalink
Revert "External Authentication Providers Support for Cody (#6526)"
Browse files Browse the repository at this point in the history
This reverts commit 1ed8392.
  • Loading branch information
umpox committed Jan 24, 2025
1 parent 7839cb4 commit 80d7b38
Show file tree
Hide file tree
Showing 45 changed files with 167 additions and 585 deletions.
80 changes: 0 additions & 80 deletions agent/scripts/reverse-proxy.py

This file was deleted.

2 changes: 1 addition & 1 deletion agent/src/AgentWorkspaceConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class AgentWorkspaceConfiguration implements vscode.WorkspaceConfiguratio

function mergeWithBaseConfig(config: any) {
for (const [key, value] of Object.entries(config)) {
if (typeof value === 'object' && !Array.isArray(value)) {
if (typeof value === 'object') {
const existing = _.get(baseConfig, key) ?? {}
const merged = _.merge(existing, value)
_.set(baseConfig, key, merged)
Expand Down
9 changes: 4 additions & 5 deletions agent/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1486,10 +1486,11 @@ export class Agent extends MessageHandler implements ExtensionClient {
config: ExtensionConfiguration,
params?: { forceAuthentication: boolean }
): Promise<AuthStatus> {
const isAuthChange = vscode_shim.isTokenOrEndpointChange(config)
const isAuthChange = vscode_shim.isAuthenticationChange(config)
vscode_shim.setExtensionConfiguration(config)

// If this is an token or endpoint change we need to save them prior to firing events that update the clients
// If this is an authentication change we need to reauthenticate prior to firing events
// that update the clients
try {
if ((isAuthChange || params?.forceAuthentication) && config.serverEndpoint) {
await authProvider.validateAndStoreCredentials(
Expand All @@ -1499,9 +1500,7 @@ export class Agent extends MessageHandler implements ExtensionClient {
},
auth: {
serverEndpoint: config.serverEndpoint,
credentials: config.accessToken
? { token: config.accessToken, source: 'paste' }
: undefined,
accessToken: config.accessToken ?? null,
},
clientState: {
anonymousUserID: config.anonymousUserID ?? null,
Expand Down
5 changes: 1 addition & 4 deletions agent/src/cli/command-auth/AuthenticatedAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ export class AuthenticatedAccount {
): Promise<AuthenticatedAccount | Error> {
const graphqlClient = SourcegraphGraphQLAPIClient.withStaticConfig({
configuration: { telemetryLevel: 'agent' },
auth: {
credentials: { token: options.accessToken },
serverEndpoint: options.endpoint,
},
auth: { accessToken: options.accessToken, serverEndpoint: options.endpoint },
clientState: { anonymousUserID: null },
})
const userInfo = await graphqlClient.getCurrentUserInfo()
Expand Down
4 changes: 2 additions & 2 deletions agent/src/cli/command-auth/command-login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ async function loginAction(
: await captureAccessTokenViaBrowserRedirect(serverEndpoint, spinner)
const client = SourcegraphGraphQLAPIClient.withStaticConfig({
configuration: { telemetryLevel: 'agent' },
auth: { credentials: { token: options.accessToken }, serverEndpoint: serverEndpoint },
auth: { accessToken: token, serverEndpoint: serverEndpoint },
clientState: { anonymousUserID: null },
})
const userInfo = await client.getCurrentUserInfo()
Expand Down Expand Up @@ -256,7 +256,7 @@ async function promptUserAboutLoginMethod(spinner: Ora, options: LoginOptions):
try {
const client = SourcegraphGraphQLAPIClient.withStaticConfig({
configuration: { telemetryLevel: 'agent' },
auth: { credentials: { token: options.accessToken }, serverEndpoint: options.endpoint },
auth: { accessToken: options.accessToken, serverEndpoint: options.endpoint },
clientState: { anonymousUserID: null },
})
const userInfo = await client.getCurrentUserInfo()
Expand Down
2 changes: 1 addition & 1 deletion agent/src/cli/command-bench/command-bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ export const benchCommand = new commander.Command('bench')
setStaticResolvedConfigurationWithAuthCredentials({
configuration: { customHeaders: {} },
auth: {
credentials: { token: options.srcAccessToken },
accessToken: options.srcAccessToken,
serverEndpoint: options.srcEndpoint,
},
})
Expand Down
5 changes: 1 addition & 4 deletions agent/src/cli/command-bench/llm-judge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ export class LlmJudge {
localStorage.setStorage('noop')
setStaticResolvedConfigurationWithAuthCredentials({
configuration: { customHeaders: undefined },
auth: {
credentials: { token: options.srcAccessToken },
serverEndpoint: options.srcEndpoint,
},
auth: { accessToken: options.srcAccessToken, serverEndpoint: options.srcEndpoint },
})
setClientCapabilities({ configuration: {}, agentCapabilities: undefined })
this.client = new SourcegraphNodeCompletionsClient()
Expand Down
5 changes: 1 addition & 4 deletions agent/src/local-e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@ export class LocalSGInstance {
// for checking the LLM configuration section.
this.gqlclient = SourcegraphGraphQLAPIClient.withStaticConfig({
configuration: { customHeaders: headers, telemetryLevel: 'agent' },
auth: {
credentials: { token: this.params.accessToken },
serverEndpoint: this.params.serverEndpoint,
},
auth: { accessToken: this.params.accessToken, serverEndpoint: this.params.serverEndpoint },
clientState: { anonymousUserID: null },
})
}
Expand Down
3 changes: 1 addition & 2 deletions agent/src/vscode-shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ export let extensionConfiguration: ExtensionConfiguration | undefined
export function setExtensionConfiguration(newConfig: ExtensionConfiguration): void {
extensionConfiguration = newConfig
}

export function isTokenOrEndpointChange(newConfig: ExtensionConfiguration): boolean {
export function isAuthenticationChange(newConfig: ExtensionConfiguration): boolean {
if (!extensionConfiguration) {
return true
}
Expand Down
29 changes: 2 additions & 27 deletions lib/shared/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,8 @@ export type TokenSource = 'redirect' | 'paste'
*/
export interface AuthCredentials {
serverEndpoint: string
credentials: HeaderCredential | TokenCredential | undefined
}

export interface HeaderCredential {
// We use function instead of property to prevent accidential top level serialization - we never want to store this data
getHeaders(): Record<string, string>
expiration: number | undefined
}

export interface TokenCredential {
token: string
source?: TokenSource
accessToken: string | null
tokenSource?: TokenSource | undefined
}

export interface AutoEditsTokenLimit {
Expand Down Expand Up @@ -81,19 +71,6 @@ export interface AgenticContextConfiguration {
}
}

export interface ExternalAuthCommand {
commandLine: readonly string[]
environment?: Record<string, string>
shell?: string
timeout?: number
windowsHide?: boolean
}

export interface ExternalAuthProvider {
endpoint: string
executable: ExternalAuthCommand
}

interface RawClientConfiguration {
net: NetConfiguration
codebase?: string
Expand Down Expand Up @@ -188,8 +165,6 @@ interface RawClientConfiguration {
*/
overrideServerEndpoint?: string | undefined
overrideAuthToken?: string | undefined

authExternalProviders: ExternalAuthProvider[]
}

/**
Expand Down
101 changes: 0 additions & 101 deletions lib/shared/src/configuration/auth-resolver.test.ts

This file was deleted.

Loading

0 comments on commit 80d7b38

Please sign in to comment.