Skip to content

Logout does not work behind reverse proxy #4503

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
code-asher opened this issue Nov 12, 2021 · 4 comments · Fixed by #4548 or #4594
Closed

Logout does not work behind reverse proxy #4503

code-asher opened this issue Nov 12, 2021 · 4 comments · Fixed by #4548 or #4594
Assignees
Labels
bug Something isn't working

Comments

@code-asher
Copy link
Member

code-asher commented Nov 12, 2021

Updated by @jsjoeio

What's the problem I'm solving?

With the latest changes to use the upstream server in code-server, we're now running into issues with our reverse proxy not using the correct URL for the Log out functionality.. The specific code we're talking about lives here.

When using a reverse proxy (i.e. Caddy/NGINX), the /logout endpoint is incorrect because it has the wrong base path and protocol.

What are some ways to go about it?

The most ideal way to solve this is to use relative endpoints. This way, code-server doesn't care about the base path or protocol. It only knows and uses relative paths.

How will things change/what is the need for maintenance?

I am not sure if there is historical context I may be missing which would explain why we didn't use a relative path from the start (or rather why upstream didn't). Patching this in vscode means it's something we'll need to keep an eye on as we continue staying in line with upstream.

I can't imagine this introducing any breaking changes but it could potentially break in specific environments if they don't support using relative paths for some reason 🤔 (though none specifically come to mind).

How to reproduce

Asher outlined steps below to reproduce this issue locally. To do so, follow these steps:

  1. install Caddy (brew install caddy)
  2. start code-server locally with yarn watch
  3. serve it at as base path like /code with Caddy
http://localhost:8082/code/* {
	uri strip_prefix /code
	reverse_proxy 127.0.0.1:8080
}
  1. navigate to http://localhost:8082/code/ (trailing slash is important!)
  2. Open the Menu and click Logout

Expected

You are redirected to http://mydomain.com/logout

Actual

You should be redirected to http://mydomain.com/code/logout

Should be similar to the fix for this issue. See PR here.

@code-asher code-asher added this to the 4.0.0 milestone Nov 12, 2021
@code-asher code-asher added the bug Something isn't working label Nov 12, 2021
@jsjoeio jsjoeio self-assigned this Nov 18, 2021
@jsjoeio
Copy link
Contributor

jsjoeio commented Nov 18, 2021

I think this will be similar to #4476

@jsjoeio
Copy link
Contributor

jsjoeio commented Dec 6, 2021

Issue

We realized after merging a fix there was an edge case. If you logout from a non-root path, it will not work.

How to reproduce

Asher outlined steps below to reproduce this issue locally. To do so, follow these steps:

  1. start code-server with yarn watch
  2. Navigate to a non-root path: http://localhost:8080/vscode
  3. Open the Menu and click Logout

Expected

You should be logged out and redirected to /vscode/login.

Actual

You are redirected to the root at http://localhost:8080 and not logged out.

Video

Screen.Recording.2021-12-07.at.2.29.10.PM.mov

Additional resources

The issue is that the base path gets set to window.location.pathname
see here: https://github.com/cdr/vscode/blob/5e0c6f3b95ed032e62c49101ae502a46c62ef202/src/vs/workbench/browser/client.ts#L194
This will be a problem with all relative paths btw
Which is why I have a function for constructing the relative base

See comment

@jsjoeio
Copy link
Contributor

jsjoeio commented Dec 7, 2021

It appears to be working as expected - you are indeed brought to the right login page and you cannot access the editor

Screen.Recording.2021-12-07.at.1.14.25.PM.mov

@code-asher - I think we can close this then unless you want to try reproducing

@jsjoeio
Copy link
Contributor

jsjoeio commented Dec 7, 2021

Update: we were missing a step in the reproduction. You need to logout from a non-root path. I will update the comment above.

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
2 participants