Theia: Support AtlasMap VS Code extension

Created on 26 Apr 2019  路  20Comments  路  Source: eclipse-theia/theia

Description

it would be nice to support VS Code AtlasMap extension.
The extension has not been published yet on VS Marketplace. The source code is located here https://github.com/jboss-fuse/vscode-atlasmap . A built vsix is available here

Reproduction Steps

  • install the extension (currently I tried using _docker run -it --rm -p 3000:3000 -p 3030:3030 -p8585:8585 -v C:/git/theia/plugins:/plugins -e THEIA_PLUGINS=local-dir:///plugins theiaide/theia-full:next_ )

Different things to try

OS and Theia version:

Windows 10
master

Diagnostics:

Currently:

  • port 8585 needs to be provided.
  • the output for AtlasMap Server is showing that the AtlasMap server is starting well
  • there is an "unhandled Navigation error" in console when opening AtlasMap (but seems to have no functional impact)
  • when trying to "export a file", there is an error: _Refused to display 'http://localhost:8585/#' in a frame because it set 'X-Frame-Options' to 'deny'._
    image
  • Progress notification is mentioning a negative progress number: "-1%"
  • Import is opening File browser for filesystem of the browser (I guess it is fine), it might be interesting to have a way to import adm files from the Theia workspace too.
bug vscode webviews

All 20 comments

for the X-Frame-options, some explanations here https://developer.mozilla.org/fr/docs/Web/HTTP/Headers/X-Frame-Options

I'm not sure who is providing the X-Frame-options.
A workaround would be to set X-Frame-Options: ALLOWALL but might not be very secure. Should be better with X-Frame-Options: ALLOW-FROM https://example.com/ but how to determine the url?

@apupier Is it about webviews? We should actually make sure that each webview is opened from own origin, otherwise any plugin can access browser shared state for the same origin, like cookies, local storage and so on.

@apupier Is it about webviews?

yes, it is from a webview.

We should actually make sure that each webview is opened from own origin, otherwise any plugin can access browser shared state for the same origin, like cookies, local storage and so on.

How are we doing that?

currently we are providing a localhost URL in the href attribute of the page used:

https://github.com/jboss-fuse/vscode-atlasmap/blob/a68b8150864cdce4040fe2be45823da3a88e82ad/src/atlasMapWebView.ts#L94

https://github.com/jboss-fuse/vscode-atlasmap/blob/a68b8150864cdce4040fe2be45823da3a88e82ad/src/extension.ts#L182

(not sure ti is relevant but seems the closer to the origin issue from my newbie point of view)

@apupier Could you change an extension to use asExternalUri instead of localhost, otherwise it is hard to make it work remotely.

@apupier please try with #6465

currently trying to setup an environment to use a non-published Che version. (but still at the very first step https://github.com/eclipse/che-theia/blob/master/CONTRIBUTING.md#step-1-start-the-workspace )

@apupier Could you change an extension to use asExternalUri instead of localhost, otherwise it is hard to make it work remotely.

need to investigate. i'm not familiar with this. Don't know what is the difference.

It makes sure that localhost request are resolved to a proper remote URI, If an extension is deployed on the remote machine. localhost although should work as well, trying to get there, a bit tricky since nested iframe is involved. We intercept聽them and redirecting to a request where Theia is deployed.

currently trying to setup an environment to use a non-published Che version. (but still at the very first step https://github.com/eclipse/che-theia/blob/master/CONTRIBUTING.md#step-1-start-the-workspace )

But does it work with local Theia already? It could be that Che needs customizations to resolve localhost properly depending how Theia is deployed there.

currently trying to setup an environment to use a non-published Che version. (but still at the very first step https://github.com/eclipse/che-theia/blob/master/CONTRIBUTING.md#step-1-start-the-workspace )

But does it work with local Theia already? It could be that Che needs customizations to resolve localhost properly depending how Theia is deployed there.

not noticed the way to launch Theia locally in the contributing guide

created jboss-fuse/vscode-atlasmap#239 to use asExternalURI

thank you! will try it as well

@apupier The extension cannot work on remote in the way how it's configured now because of CSP violations:

Access to font at 'http://localhost:8586/OpenSans-Regular-webfont.woff2' from origin 'https://webview-3000-d6dcec72-ba2f-49e9-9f72-4ff0446f67ec.ws-eu01.gitpod.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

https://webview-3000-d6dcec72-ba2f-49e9-9f72-4ff0446f67ec.ws-eu01.gitpod.io is an origin for webviews and it's provided as a scp source, but then the extension resets base of content to http://localhost:8586 which is not covered by the scp source. anExtensionUri will generate an URI similar to the scp source, then it will work.

Trying the version from the PR now.

Trying the version from the PR now.

I'm trying the PR, but for some reasons the server does not start for me anymore. Do you know what could it be?

I'm trying the PR, but for some reasons the server does not start for me anymore. Do you know what could it be?

Do you mean the Webview is not opening? The webview is blank? the webview is giving a 404? You don't see any process for atlasmap when calling ps -edf |grep java | grep atlasmap?

When you stop everything, do you still have a process visible with ps -edf |grep java | grep atlasmap? If yes, can you try to kill it and relaunch.

Trying AtlasMap with the asExternalURI PR inside local Che theia based on you rPR branch.
The AtlasMap Ui is nto displayed.
There are 404 errors on the resources from the page:

runtime.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
polyfills.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
styles.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
scripts.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
vendor.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
main.js:1 Failed to load resource: the server responded with a status of 404 (Not Found

the exact link is like that:
http://2d5aedd4-d207-4239-bee4-4c04ef449db2.webview.localhost:3000/runtime.js

effectively I cannot reach it if I enter the URl directly in the browser.
I can reach it through http://localhost:8585/runtime.js

Yes, a result returned by asExternalUri cannot be fetched from where the extension is running, I've commented on https://github.com/jboss-fuse/vscode-atlasmap/pull/239 how to use it properly.

Regarding running the server, i forgot to run npm i to download a jar file, it is fine now :)

I'm not sure who is providing the X-Frame-options.
A workaround would be to set X-Frame-Options: ALLOWALL but might not be very secure. Should be better with X-Frame-Options: ALLOW-FROM https://example.com/ but how to determine the url?

Now, i understand the issue clearly. I think you should file an issue for atlasmap. I don't see how we can work it around in Theia.

@apupier I've merged https://github.com/eclipse-theia/theia/pull/6465. Now accessing localhost resources should work in remote env. Although issue with X-Frame-Options i think you need to sort out with atlasmap.

I'm closing it now. Please reopen if you think something else could be done on our side.

Was this page helpful?
0 / 5 - 0 ratings