Skip to content

Allow login while proxing a sub-domain - #2186

Closed
code-asher wants to merge 1 commit into
masterfrom
proxy-login
Closed

code-asher wants to merge 1 commit into
masterfrom
proxy-login

Conversation

@code-asher

Copy link
Copy Markdown
Member

Fixes #2128.

@code-asher

Copy link
Copy Markdown
Member Author

tbh this feels a little jank to me but I'm not sure how else this could be implemented.

Comment thread src/node/http.ts
if (!route.provider.authenticated(request)) {
// Attempt to determine if it's the user browsing the root and if so fall
// through to allow the login flow.
if (request.headers["content-type"] !== "application/json") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's check explicitly for text/html here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I wanted to do that but Firefox and Chromium don't seem to set this at all. When I logged it the value was undefined.

Comment thread src/node/http.ts
// Must be authenticated to use the proxy.
route.provider.ensureAuthenticated(request)
if (!route.provider.authenticated(request)) {
// Attempt to determine if it's the user browsing the root and if so fall

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Attempt to determine if it's the user browsing the root and if so fall
// Attempt to determine if it's the user browsing the route and if so fall

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I mean root, for example 8080.mydomain.com and not 8080.mydomain.com/some/page. Maybe we should always redirect though even if it's not the root.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Well I guess we can't do that safely, it would end up causing the problem in #2128 again on account of the whole not being able to detect HTML nonsense.

Comment thread src/node/http.ts
// Attempt to determine if it's the user browsing the root and if so fall
// through to allow the login flow.
if (request.headers["content-type"] !== "application/json") {
switch (route.providerBase) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm confused by this, don't we pretty always want to fall through to the login flow if text/html is asked for but the user isn't authenticated?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yup, if there was a way to reliably detect the request was asking for HTML (and ideally also that it wasn't an xhr request) that would 100% be the way to do it. All this jank is to work around not being able to do that (at least as far as I know, I hope I'm wrong though).

@code-asher

Copy link
Copy Markdown
Member Author

Pretty much all of this conflicts with the Express rewrite so I'm going to bundle it into that PR.

@code-asher code-asher closed this Oct 26, 2020
@code-asher
code-asher deleted the proxy-login branch October 26, 2020 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Catch unauthenticated POST requests to the proxy and return an error instead of redirecting to vs code

2 participants