Skip to content

fix: avoid redirect loop on workspace proxies#9389

Merged
Emyrk merged 5 commits into
mainfrom
dean/fix-app-redirect-loop
Aug 29, 2023
Merged

fix: avoid redirect loop on workspace proxies#9389
Emyrk merged 5 commits into
mainfrom
dean/fix-app-redirect-loop

Conversation

@deansheather
Copy link
Copy Markdown
Member

@deansheather deansheather commented Aug 28, 2023

Changes the old coder_devurl_session_token cookie to be two new cookies: coder_path_app_session_token and coder_subdomain_app_session_token. This avoids cases where the cookie for both europe.dev.coder.com and .europe.dev.coder.com are both sent to Coder, but we can only set europe.dev.coder.com on path apps.

Changes the signed app token generating and comparing code to always append / to the base path to avoid generating two signed tokens when redirecting from /@user/workspace/apps/app to /@user/workspace/apps/app/ (trailing slash redirect).

We will also now try to validate up to 4 signed app token cookies in the request in case multiple cookies are specified by the browser. Browsers will send all cookies with the same name but different paths, not only a single one with the most specific path.

TODO:

  • Test manually in a browser
  • Add tests for not being able to use the incorrect cookie on the wrong access method
  • Add tests for supplying multiple signed app token cookies in a request and them all being tried (up to 4)

Closes #9109

Comment on lines +106 to +109
if !strings.HasSuffix(req.BasePath, "/") {
req.BasePath += "/"
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Doing it here 👍

@Emyrk
Copy link
Copy Markdown
Member

Emyrk commented Aug 28, 2023

Veried on a local deployment and path based apps.

Copy link
Copy Markdown
Member

@Emyrk Emyrk left a comment

Choose a reason for hiding this comment

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

I just added tests to @deansheather's PR 👍

@Emyrk Emyrk merged commit 5993f85 into main Aug 29, 2023
@Emyrk Emyrk deleted the dean/fix-app-redirect-loop branch August 29, 2023 01:34
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blank screen when accessing code-server

2 participants