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

GitHub login redirect fails due to missing subpath #4107

Open
Nick-Hopps opened this issue Sep 5, 2021 · 31 comments
Open

GitHub login redirect fails due to missing subpath #4107

Nick-Hopps opened this issue Sep 5, 2021 · 31 comments
Labels
bug Something isn't working

Comments

@Nick-Hopps
Copy link

OS/Web Information

  • Web Browser: Firefox
  • Local OS: Windows10
  • Remote OS: Ubuntu 20.04
  • Remote Architecture: amd64
  • code-server --version: 3.11.1

Steps to Reproduce

  1. click the link: 图片
  2. The page shows 404 not found.
  3. Login failed.

Expected

Login to github without failing.

Actual

Failed logining into GitHub.

Logs

Screenshot

Notes

This issue can be reproduced in VS Code: No

@Nick-Hopps
Copy link
Author

I'm using code-server under reverse proxy, which is handled by Nginx, My config is:

server {
    listen 8080;
    server_name xxx.com;

    location /code-server/ {
        proxy_set_header Host $host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection upgrade;
        proxy_pass http://10.0.0.1:8000/;
    }
}

@Nick-Hopps
Copy link
Author

After investigation, I found that it was the authentication URL which lead to the failing:

https://xxx.com/callback?vscode-requestId=......

It suppose to be:

https://xxx.com/code-server/callback?vscode-requestId=......

Is there any workaroud to deal with such situation? I've tried some but failed.

@jsjoeio
Copy link
Contributor

jsjoeio commented Sep 7, 2021

For whatever reason, I can't seem to find the "Sign in with GitHub" from GitLens.

image

If it's the authentication URL, you should be able to modify it manually:

see #1883 (comment)

Let me know if that works!

@Nick-Hopps
Copy link
Author

Here is the entrance:

image

I've tried that approach, but it results in Bad Request.

@Nick-Hopps
Copy link
Author

Nick-Hopps commented Sep 8, 2021

For the origin URL:

image

When adding my subpath "/code-server/" to the host name:

image

Since the page shows the expected result(however nothing happened to code-server), so I think maybe fix the request URL may help.

@jsjoeio
Copy link
Contributor

jsjoeio commented Sep 8, 2021

Thanks for the screenshots!

So I clicked on that, it asked for a PAT, I copied one from https://github.com/settings/tokens and it worked? Can you try that approach instead of the auth URL callback?

image

image

@jsjoeio jsjoeio added the waiting-for-info Waiting for more information from submitter label Sep 8, 2021
@Nick-Hopps
Copy link
Author

Wow, it works for me! Thx very much. If only callback also works, it'd be perfect.

@jsjoeio
Copy link
Contributor

jsjoeio commented Sep 9, 2021

I'll let @code-asher chime in and see if he is able to reproduce the issue with the callback

@Nick-Hopps
Copy link
Author

waiting for good news 😄

@code-asher
Copy link
Member

code-asher commented Sep 10, 2021 via email

@jsjoeio jsjoeio changed the title Failed logining into GitHub. GitHub login redirect fails due to missing subpath Sep 10, 2021
@jsjoeio jsjoeio added bug Something isn't working and removed waiting-for-info Waiting for more information from submitter labels Sep 10, 2021
@jsjoeio jsjoeio added this to the On Deck milestone Sep 10, 2021
@jsjoeio
Copy link
Contributor

jsjoeio commented Sep 10, 2021

No worries! I've changed the title to reflect so and added to On Deck. @Nick-Hopps can't tell you when we'll get to it, but it's on the list and will be in an upcoming milestone in the future!

@Nick-Hopps
Copy link
Author

No worries! I've changed the title to reflect so and added to On Deck. @Nick-Hopps can't tell you when we'll get to it, but it's on the list and will be in an upcoming milestone in the future!

It's ok and thx again.

@gmrukwa
Copy link

gmrukwa commented Dec 12, 2021

Thanks for the screenshots!

So I clicked on that, it asked for a PAT, I copied one from https://github.com/settings/tokens and it worked? Can you try that approach instead of the auth URL callback?

image

image

I am using such an approach, but it asks me for the token each time I do git pull or anything else that requires authentication. It just drives me crazy. The answer I suggested here and the solution from that thread don't work anymore. Is there any better solution?

I do have a reverse proxy, too. I replace the corresponding part of the URL, but it doesn't help, exactly like in the case of @Nick-Hopps.

@jsjoeio
Copy link
Contributor

jsjoeio commented Dec 13, 2021

I am using such an approach, but it asks me for the token each time I do git pull or anything else that requires authentication.

Usually when this happens, I think it means git isn't caching your credentials. Have you tried this?

@gmrukwa
Copy link

gmrukwa commented Dec 13, 2021

I am using such an approach, but it asks me for the token each time I do git pull or anything else that requires authentication.

Usually when this happens, I think it means git isn't caching your credentials. Have you tried this?

Thanks, it worked. My bad, didn't check this, just thought it's an issue with the code-server. 🤦🏻

@jsjoeio
Copy link
Contributor

jsjoeio commented Dec 14, 2021

My bad, didn't check this, just thought it's an issue with the code-server. 🤦🏻

Happens to all of us once in a while! Glad that's resolved :)

@twittyc
Copy link

twittyc commented Apr 22, 2022

Hello, If I can be pointed in the right direction. I don't mind doing the work to fix this bug since it affects me. I'm not sure where the callback is in the code.

@jsjoeio
Copy link
Contributor

jsjoeio commented Apr 22, 2022

This is our GitHub auth patch so that's where the code for this should be. That would be a good place to start

@code-asher
Copy link
Member

I think I might have fixed this (I must have forgotten this issue existed). Is is still present in latest code-server?

@twittyc
Copy link

twittyc commented Apr 25, 2022

I cannot complete the OAuth flow for Gitlens+ login (required for their subscription). So I believe so.

@code-asher
Copy link
Member

code-asher commented Apr 28, 2022

Ahhh my bad I was thinking about the builtin git extension.

It looks like GitLens uses asExternalUri to generate the redirect URI:
https://github.com/gitkraken/vscode-gitlens/blob/ec6e207eae89c87152cff89d70f415cc82602527/src/plus/subscription/serverConnection.ts#L113-L120

So I bet we need to patch asExternalUri to include the full path rather than just the host.

@code-asher
Copy link
Member

code-asher commented Oct 11, 2022 via email

@code-asher
Copy link
Member

code-asher commented Oct 13, 2022

Nearly six months for this comment that I initially sent through email to arrive. How strange. 😛

@Msadat97
Copy link

Msadat97 commented Dec 7, 2022

Is there a fix for this? When I use GitLense Sign-in, it redirects me to the GitLense page, but from there, I cannot authorize anything for the code-server. It always opens the local vscode.

image

The sign-in option in the code-server opens this page instead of the authorization page.

@jsjoeio
Copy link
Contributor

jsjoeio commented Dec 7, 2022

@Msadat97 what version of code-server are you using? and can you provide repro steps? i can look into it

@Msadat97
Copy link

Msadat97 commented Dec 8, 2022

I am using the latest version (4.9.0) of code-server. To reproduce this, you can go to the sidebar page of the GitLens extension and click on the sign-in option.

Screenshot 2022-12-08 at 11 08 32

Then, it doesn't redirect to the correct page.

@jsjoeio
Copy link
Contributor

jsjoeio commented Dec 8, 2022

Are there any logs in the browser console? And what page does it redirect to?

@Msadat97
Copy link

Msadat97 commented Dec 9, 2022

It basically does nothing other than opening the page that I sent before:

image

These are the logs that I get, which I think are not relevant.

DevTools failed to load source map: Could not load content for chrome-extension://bmnlcjabgnpnenekpadlanbbkooimhnj/browser-polyfill.js.map: System error: net::ERR_BLOCKED_BY_CLIENT
DevTools failed to load source map: Could not load content for chrome-extension://nllcnknpjnininklegdoijpljgdjkijc/bundles/content.js.map: System error: net::ERR_BLOCKED_BY_CLIENT
DevTools failed to load source map: Could not load content for chrome-extension://nllcnknpjnininklegdoijpljgdjkijc/bundles/writingMonitor.js.map: System error: net::ERR_BLOCKED_BY_CLIENT
DevTools failed to load source map: Could not load content for chrome-extension://nllcnknpjnininklegdoijpljgdjkijc/bundles/content.js.map: System error: net::ERR_BLOCKED_BY_CLIENT
DevTools failed to load source map: Could not load content for chrome-extension://nllcnknpjnininklegdoijpljgdjkijc/bundles/writingMonitor.js.map: System error: net::ERR_BLOCKED_BY_CLIENT
DevTools failed to load source map: Could not load content for chrome-extension://nllcnknpjnininklegdoijpljgdjkijc/bundles/content.js.map: System error: net::ERR_BLOCKED_BY_CLIENT
DevTools failed to load source map: Could not load content for chrome-extension://nllcnknpjnininklegdoijpljgdjkijc/bundles/writingMonitor.js.map: System error: net::ERR_BLOCKED_BY_CLIENT

@jsjoeio
Copy link
Contributor

jsjoeio commented Dec 12, 2022

I can't find the authorization URL it's looking for either.

Screen.Recording.2022-12-12.at.8.56.43.AM.mov

Can you try raising an issue with GitLens? Seems like it's not giving us the authorization URL to paste into code-server.

@Msadat97
Copy link

Msadat97 commented Dec 20, 2022

Sure. I will mention the issue with the GitLens team.

@amirhmoradi
Copy link

Here is the solution to connect your GitLens Pro account in hosted code-server:
1: Click on the signing link as shown in the screenshot:
signin-gitlens-code-server

2: Allow the usage of GitLens+:
signin-gitlens-code-server-allow

3: "Copy" the link:
signin-gitlens-copy-link

4: From the link, extract the gkstate value:
example: b4bbb363-b3e5-4014-efb8-a7a0f9e42135

5: Replace GKSTATE_HERE in the link below with your own gkstate:
⚠️ Careful not to touch the D before, nor the % after the gkstate.

https://app.gitkraken.com/register?referrer=gitlens&pass-token=true&return-url=vscode%3A%2F%2Feamodio.gitlens%2Fdid-authenticate%3Fgkstate%253DGKSTATE_HERE%2526windowId%253D2

6: Open the new URL from step 5 in your browser (not in code-server) and connect to your GitLens Pro account, then the page would redirect to a validation page where you must copy the Authorization URL (do not click on Open in VSCode, if the popup is presented to you as this will open the local vscode and not your hosted Code-Server)
signin-gitlens-copy-authorization-url

7: Paste the Authorization URL in the popup in Code-Server:
signin-gitlens-paste-url-and-enter

8: Voila:
code-server-gitlens-pro-signin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants