Skip to content
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: do not reject unknown schemes in WindowStateExt.asExternalUri #13057

Merged
merged 1 commit into from
Dec 14, 2023

Conversation

AlexandraBuzila
Copy link
Contributor

@AlexandraBuzila AlexandraBuzila commented Nov 6, 2023

What it does

Fixes #12821

After testing the same workflow of the Gitlens extension in VS Code, I think URLs with unknown schemes were rejected prematurely in Theia.
When the Connect to Github action is triggered, the extension invokes two methods of the WindowStateExtImpl: first asExternalUri and at a later point openUri.

The parameter passed to the asExternalUri method is an URI of the form theia://... and the existing code rejects it.
In VS Code, the URI has an application specific schema as well (not http or https), but the code does not reject it. This allows the Github authentication to process the request and later on call the openUri method with a valid URI.

I modified the code and it now handles URIs similar to VS Code. This fixes the initial problem, which was reported for the gitlens extension, but I would love some feedback as I can't tell if this is generally safe for all extensions.

How to test

  1. Install gitlens. I had to remove the vscode.git and vscode.github extensions from the excluded plugins list and removed the '@theia/git' package to make this work with the Theia examples.
  2. Open an editor on a file in a github repo, for example theia itself.
  3. When you hover at the end of a line, you get a hover that shows you information about the commit that last changed this line.
  4. Scroll to the bottom of the hover
  5. Observe: there is a link that says "Connect to Github".
  6. Click the link
  7. There's a popup that says "You have not yet finished authorizing this extension ...". Click 'Yes'.
  8. Another popup shows up - click "Copy & Continue to Github".
  9. A Github link should open in the browser.

Review checklist

Reminder for reviewers

Contributed on behalf of STMicroelectronics

@JonasHelming
Copy link
Contributor

@AlexandraBuzila Is this ready for a re-review?

@tsmaeder
Copy link
Contributor

The "Connect to Github..." workflow still does not work for me: when I invoke it, nothing happens and I get a dialog saying

Sie haben die Autorisierung dieser Erweiterung für die Verwendung von GitHub noch nicht abgeschlossen. Möchten Sie eine andere Methode ausprobieren? (Gerätecode)

I would expect to be redirected to the github authentication page.

@AlexandraBuzila
Copy link
Contributor Author

I would expect to be redirected to the github authentication page.

Does the link open in the browser if you confirm that dialog?

I see now that the workflow in vscode looks different: you are asked to log in, while in theia you are asked to use another login method. I can check to see where the difference is coming from.

@JonasHelming
Copy link
Contributor

@tsmaeder Opne question above :-)

@tsmaeder
Copy link
Contributor

Does the link open in the browser if you confirm that dialog?

No

Copy link
Contributor

@tsmaeder tsmaeder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After retesting, the login seems to work now.

Fixes #128210

Contributed on behalf of STMicroelectronics

Signed-off-by: Alexandra Buzila <abuzila@eclipsesource.com>
@tsmaeder tsmaeder merged commit ee085d5 into eclipse-theia:master Dec 14, 2023
14 checks passed
@vince-fugnitto vince-fugnitto added this to the 1.45.0 milestone Dec 21, 2023
@planger
Copy link
Contributor

planger commented Jan 26, 2024

I'm very much looking forward to having this up and running.

So I tried with today's master, removed the git and github related extensions from theiaPluginsExcludeIds and tried the Github view as well as exactly the steps from this PR with Gitlens. When trying to connect to Github, I just received this though:
image

No browser window was opened. Do you have any suggestion @AlexandraBuzila? Thank you!

@AndKe
Copy link

AndKe commented Apr 9, 2024

Joining in as I too am very interested in this feature and I stop at the same issue as the post above.

@planger
Copy link
Contributor

planger commented Apr 9, 2024

@AlexandraBuzila @tsmaeder Do you have feedback on the issue mentioned above? Should we re-open this issue?

@tsmaeder
Copy link
Contributor

tsmaeder commented Apr 9, 2024

@AndKe how exactly is this failing for you? What's your setup for running Theia?

@AndKe
Copy link

AndKe commented Apr 9, 2024

@tsmaeder - I recieved good help from @planger to get this far: (so our methods are most likely more or less the same)

I started with copying my working plugins from vscode:
cp ~/.vscode/extensions/github.co* ~/.arduinoIDE/plugins
downloaded the .vsix from https://open-vsx.org/extension/vscode/github-authentication and copied it into .vsix file to the ~/.arduinoIDE/plugins
Then I started the arduino-ide_2.3.3-snapshot-de5b91f_Linux_64bit.AppImage

What I got was :
Screenshot from 2024-04-09 18-13-10
then clicked yes and got:

Screenshot from 2024-04-09 18-13-57

It may be worth mentioning that my copilot for vscode authentication also failed to spawn a browser window, like Arduino IDE fell back to alternative method.
PyCharm plugin, however authenticated perfectly smooth.

@tsmaeder
Copy link
Contributor

tsmaeder commented Apr 10, 2024

@AndKe arduinoIDE is still on Theia release 1.41.0. The fix is not in that version.

@AndKe
Copy link

AndKe commented Apr 10, 2024

@tsmaeder are you saying that is should work in >= 1.41 ? / and where can I get that version?

@per1234
Copy link
Contributor

per1234 commented Apr 10, 2024

@AndKe you must have forgotten the details of the discussion we had about this over on Arduino Forum. The "arduino-ide_2.3.3-snapshot-de5b91f_Linux_64bit.AppImage" you are using is a beta tester build of Arduino IDE with Theia version 1.46.1 (arduino/arduino-ide@de5b91f):

https://github.com/arduino/arduino-ide/actions/runs/8596568336#artifacts

@tsmaeder
Copy link
Contributor

@AndKe as the PR was merged in Dec., it should be in 1.46.1.

I started with copying my working plugins from vscode:

This is not a good idea: when we download plugins, we select a version of the built-ins that works with that particular Theia version.

As for the gitlens example from the testing instructions, I don't even get the "Connect to Github" link anymore. Reopening.

@AlexandraBuzila AlexandraBuzila deleted the fix/connect-to-github branch May 29, 2024 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Cannot "Connect to Github"
7 participants