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
fix: allow the extensions to authenticate #339
Merged
Merged
Changes from 27 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
9da511a
fix: the extension should get a session
vitaliy-guliy 10c6de2
add extra output
vitaliy-guliy b73af0d
update
vitaliy-guliy 28abe2b
Merge branch 'main' into copilot-chat-simplified
vitaliy-guliy 206d690
update
vitaliy-guliy 6b8ec4e
update
vitaliy-guliy 15de59e
update
vitaliy-guliy 7d27351
update
vitaliy-guliy f0ff574
update
vitaliy-guliy 042fbc1
update
vitaliy-guliy e790ba4
update
vitaliy-guliy 256e840
update
vitaliy-guliy c0995c2
update
vitaliy-guliy 3b962ab
update
vitaliy-guliy 9ec294d
update
vitaliy-guliy ea5e656
update
vitaliy-guliy 9ac0aad
update
vitaliy-guliy 57bf1f8
update
vitaliy-guliy d523459
update
vitaliy-guliy dc3d351
update
vitaliy-guliy c92f56c
update
vitaliy-guliy a7c1af5
update
vitaliy-guliy b451c84
Merge branch 'main' into copilot-chat-simplified
vitaliy-guliy ed1841b
update
vitaliy-guliy bacface
update
vitaliy-guliy cf14e08
update
vitaliy-guliy 8c6de55
update
vitaliy-guliy a924544
update
vitaliy-guliy 7b1ad9f
Merge branch 'main' into copilot-chat-simplified
vitaliy-guliy File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
10 changes: 10 additions & 0 deletions
10
.rebase/replace/code/src/vs/platform/product/common/product.ts.json
This file contains 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,10 @@ | ||
[ | ||
{ | ||
"from": "import { ISandboxConfiguration } from 'vs/base/parts/sandbox/common/sandboxTypes';", | ||
"by": "import { ISandboxConfiguration } from 'vs/base/parts/sandbox/common/sandboxTypes';\\\nimport { loadFromFileSystem } from 'vs/platform/product/common/che/product';" | ||
}, | ||
{ | ||
"from": "product = { /\\*BUILD->INSERT_PRODUCT_CONFIGURATION\\*/ } as IProductConfiguration;", | ||
"by": "product = { /\\*BUILD->INSERT_PRODUCT_CONFIGURATION\\*/ } as IProductConfiguration;\\\n\\\tproduct = loadFromFileSystem();" | ||
} | ||
] |
This file contains 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 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,32 @@ | ||
/********************************************************************** | ||
* Copyright (c) 2024 Red Hat, Inc. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
***********************************************************************/ | ||
/* eslint-disable header/header */ | ||
|
||
import { IProductConfiguration } from 'vs/base/common/product'; | ||
|
||
export function loadFromFileSystem(): IProductConfiguration { | ||
const href = `./oss-dev/static/product.json`; | ||
|
||
try { | ||
var xmlhttp = new XMLHttpRequest(); | ||
xmlhttp.open("GET", href, false); | ||
xmlhttp.send(); | ||
|
||
if (xmlhttp.status == 200 && xmlhttp.readyState == 4) { | ||
return JSON.parse(xmlhttp.responseText); | ||
} | ||
|
||
console.log(`Request failed with status: ${xmlhttp.status}, readyState: ${xmlhttp.readyState}`); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
|
||
throw new Error(`Unable to load product.json from ${href}.`); | ||
} |
This file contains 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 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 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 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,64 @@ | ||
/********************************************************************** | ||
* Copyright (c) 2024 Red Hat, Inc. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
***********************************************************************/ | ||
|
||
import { env } from 'process'; | ||
import { ProductJSON } from './product-json'; | ||
|
||
export class TrustedExtensions { | ||
async configure(): Promise<void> { | ||
console.log('# Configuring Trusted Extensions...'); | ||
|
||
if (!env.VSCODE_TRUSTED_EXTENSIONS) { | ||
console.log(' > env.VSCODE_TRUSTED_EXTENSIONS is not defined, skip this step'); | ||
return; | ||
} | ||
|
||
try { | ||
const extensions: string[] = []; | ||
|
||
for (const extension of env.VSCODE_TRUSTED_EXTENSIONS.split(',')) { | ||
if (extension) { | ||
extensions.push(extension); | ||
console.log(` > add ${extension}`); | ||
} | ||
} | ||
|
||
if (!extensions.length) { | ||
console.log(' > env.VSCODE_TRUSTED_EXTENSIONS does not specify any extension'); | ||
return; | ||
} | ||
|
||
const productJSON = await new ProductJSON().load(); | ||
let productJSONChanged = false; | ||
|
||
let access = productJSON.getTrustedExtensionAuthAccess(); | ||
if (access === undefined) { | ||
productJSON.setTrustedExtensionAuthAccess([...extensions]); | ||
productJSONChanged = true; | ||
} else if (Array.isArray(access)) { | ||
for (const extension of extensions) { | ||
if (!access.includes(extension)) { | ||
access.push(extension); | ||
productJSONChanged = true; | ||
} | ||
} | ||
} else { | ||
console.log(' > Unexpected type of trustedExtensionAuthAccess in product.json. Skip this step'); | ||
return; | ||
} | ||
|
||
if (productJSONChanged) { | ||
await productJSON.save(); | ||
} | ||
} catch (err) { | ||
console.error(`${err.message} Failure to configure trusted extensions in product.json.`); | ||
} | ||
} | ||
} |
This file contains 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
Oops, something went wrong.
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.
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.
I think it makes sense to add the value of the variable to the log
Let's say another separator is applied by a user, then:
extensions
array is emptyenv.VSCODE_TRUSTED_EXTENSIONS does not specify any extension
is NOT trueThere 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.
User specified
env.VSCODE_TRUSTED_EXTENSIONS
in his devfile.Launcher says that
env.VSCODE_TRUSTED_EXTENSIONS
is wrong.No need here to duplicate the value.
From the other side, if you have an idea, please share it.
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.
yes,
Launcher says that env.VSCODE_TRUSTED_EXTENSIONS is wrong.
but the launcher says nothing about:
You use here
,
as a separator for theVSCODE_TRUSTED_EXTENSIONS
env var,but, for example,
PATH
env variable uses:
as a separatorIf a user uses
:
as a separator (just out of habit) for theVSCODE_TRUSTED_EXTENSIONS
then:VSCODE_TRUSTED_EXTENSIONS
is defined, it's not empty, it contains extensionsMy propose was just clarify it in logs - like - if the logic can not handle the variable - then it should be clear:
VSCODE_TRUSTED_EXTENSIONS
hassome value here
=>,
as a separator to parse extensions =>VSCODE_TRUSTED_EXTENSIONS
will be ignored =>VSCODE_TRUSTED_EXTENSIONS
is:some-value,another-value
============
anyway I've approved your pull request yesterday, these changes are minor, it's up to you
so feel free to merge the pull request as soon as you believe it's good enough
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.
Have just played with it and would say, that the cheapest way in case of errors is to print the current value of
VSCODE_TRUSTED_EXTENSIONS
environment variable and explain that it should contain one or several extension identifiers divided by comma.It's for the first step.
The next, I think we should document the functionality provided by launcher. Among them, ability to configure trusted extensions, location of Open VSX registry, webviews, etc.
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.
The output with one failed extension
The output when the variable does not specify anything