-
Notifications
You must be signed in to change notification settings - Fork 747
fix(amazonq): Add proxy configuration support with SSL Cert Validation #7422
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| /*! | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import vscode from 'vscode' | ||
| import { getLogger } from '../logger/logger' | ||
|
|
||
| interface ProxyConfig { | ||
| proxyUrl: string | undefined | ||
| certificateAuthority: string | undefined | ||
| username: string | undefined | ||
| password: string | undefined | ||
| } | ||
|
|
||
| /** | ||
| * Utility class for handling proxy configuration | ||
| */ | ||
| export class ProxyUtil { | ||
| private static readonly logger = getLogger('proxyUtil') | ||
|
|
||
| /** | ||
| * Sets proxy environment variables based on VS Code settings for use with the Flare Language Server | ||
| * | ||
| * See documentation here for setting the environement variables which are inherited by Flare LS process: | ||
| * https://github.com/aws/language-server-runtimes/blob/main/runtimes/docs/proxy.md | ||
| */ | ||
| public static configureProxyForLanguageServer(): void { | ||
| try { | ||
| const proxyConfig = this.getProxyConfiguration() | ||
|
|
||
| this.setProxyEnvironmentVariables(proxyConfig) | ||
| } catch (err) { | ||
| this.logger.error(`Failed to configure proxy: ${err}`) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Gets proxy configuration from VS Code settings | ||
| */ | ||
| private static getProxyConfiguration(): ProxyConfig { | ||
| const httpConfig = vscode.workspace.getConfiguration('http') | ||
| const proxyUrl = httpConfig.get<string>('proxy') | ||
| this.logger.debug(`Proxy URL: ${proxyUrl}`) | ||
|
|
||
| const amazonQConfig = vscode.workspace.getConfiguration('amazonQ') | ||
| const proxySettings = amazonQConfig.get<{ | ||
| certificateAuthority?: string | ||
| username?: string | ||
| password?: string | ||
| }>('proxy', {}) | ||
|
|
||
| return { | ||
| proxyUrl, | ||
| certificateAuthority: proxySettings.certificateAuthority, | ||
| username: proxySettings.username, | ||
| password: proxySettings.password, | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Sets environment variables based on proxy configuration | ||
| */ | ||
| private static setProxyEnvironmentVariables(config: ProxyConfig): void { | ||
| let proxyUrl = config.proxyUrl | ||
|
|
||
| // Add authentication to proxy URL if provided | ||
| if (proxyUrl && config.username && config.password) { | ||
| try { | ||
| const parsedUrl = new URL(proxyUrl) | ||
| const protocol = parsedUrl.protocol | ||
| const host = parsedUrl.hostname | ||
| const port = parsedUrl.port || (protocol === 'https:' ? '443' : '80') | ||
|
|
||
| proxyUrl = `${protocol}//${config.username}:${config.password}@${host}:${port}` | ||
| this.logger.debug('Added authentication to proxy URL') | ||
| } catch (err) { | ||
| this.logger.error(`Failed to parse proxy URL: ${err}`) | ||
| } | ||
| } | ||
|
|
||
| // Always enable experimental proxy support for better handling of both explicit and transparent proxies | ||
| process.env.EXPERIMENTAL_HTTP_PROXY_SUPPORT = 'true' | ||
|
|
||
| // Set proxy environment variables | ||
| if (proxyUrl) { | ||
| process.env.HTTPS_PROXY = proxyUrl | ||
| process.env.HTTP_PROXY = proxyUrl | ||
| this.logger.debug(`Set proxy environment variables: ${proxyUrl}`) | ||
| } | ||
|
|
||
| // Set certificate bundle environment variables if configured | ||
| if (config.certificateAuthority) { | ||
| process.env.NODE_EXTRA_CA_CERTS = config.certificateAuthority | ||
| process.env.AWS_CA_BUNDLE = config.certificateAuthority | ||
| this.logger.debug(`Set certificate bundle path: ${config.certificateAuthority}`) | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.