-
Notifications
You must be signed in to change notification settings - Fork 351
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
Add support for external auth providers in code search #6919
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,6 @@ class CodySettingChangeListener(project: Project) : ChangeListener(project) { | |
CodySettingChangeActionNotifier.TOPIC, | ||
object : CodySettingChangeActionNotifier { | ||
override fun afterAction(context: CodySettingChangeContext) { | ||
// Notify JCEF about the config changes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't we need to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That config was already not containing any info useful for sourcegraph search. |
||
javaToJSBridge?.callJS("pluginSettingsChanged", ConfigUtil.getConfigAsJson(project)) | ||
|
||
if (context.oldCodyEnabled != context.newCodyEnabled) { | ||
if (context.newCodyEnabled) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,17 +36,26 @@ export function toPartialUtf8String(buf: Buffer): { str: string; buf: Buffer } { | |
} | ||
} | ||
|
||
export async function addAuthHeaders(auth: AuthCredentials, headers: Headers, url: URL): Promise<void> { | ||
export async function getAuthHeaders(auth: AuthCredentials, url: URL): Promise<Record<string, string>> { | ||
// We want to be sure we sent authorization headers only to the valid endpoint | ||
if (auth.credentials && url.host === new URL(auth.serverEndpoint).host) { | ||
if ('token' in auth.credentials) { | ||
headers.set('Authorization', `token ${auth.credentials.token}`) | ||
} else if (typeof auth.credentials.getHeaders === 'function') { | ||
for (const [key, value] of Object.entries(await auth.credentials.getHeaders())) { | ||
headers.set(key, value) | ||
} | ||
} else { | ||
console.error('Cannot add headers: neither token nor headers found') | ||
return { Authorization: `token ${auth.credentials.token}` } | ||
} | ||
if (typeof auth.credentials.getHeaders === 'function') { | ||
return await auth.credentials.getHeaders() | ||
} | ||
} | ||
|
||
console.error('Cannot add headers: neither token nor headers found') | ||
|
||
return {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. previously we had a |
||
} | ||
|
||
export async function addAuthHeaders(auth: AuthCredentials, headers: Headers, url: URL): Promise<void> { | ||
await getAuthHeaders(auth, url).then(authHeaders => { | ||
for (const [key, value] of Object.entries(authHeaders)) { | ||
headers.set(key, value) | ||
} | ||
}) | ||
} |
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.
nice