Skip to content

[server] Fix domain scope for session cookie#1903

Merged
AlexTugarev merged 1 commit intomasterfrom
at/session-fix
Oct 16, 2020
Merged

[server] Fix domain scope for session cookie#1903
AlexTugarev merged 1 commit intomasterfrom
at/session-fix

Conversation

@AlexTugarev
Copy link
Copy Markdown
Member

@AlexTugarev AlexTugarev commented Sep 25, 2020

With this change slicing of hostname will only be applied for preview environments.

ACK this still only works for preview environments deployed without a 2nd level TLD.
OTOH it should quickly enable SH installations with 2nd level TLDs!

Fixes #1887

@jankeromnes
Copy link
Copy Markdown
Contributor

jankeromnes commented Sep 25, 2020

Failed with:

  1) UserDBSpec
       "before each" hook for "createUserAndFindById":
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

We should really figure out how to configure the timeout for the "before each" hook in our tests, because at 2s they time out quite often.

/werft run

👍 started the job as gitpod-build-at-session-fix.1

With this change slicing of hostname will only be applied for preview environments.

ACK this still only works for preview environments deployed without a 2nd level TLD.
OTOH it should quickly enable SH installations with 2nd level TLDs!
@AlexTugarev
Copy link
Copy Markdown
Member Author

AlexTugarev commented Sep 25, 2020

/werft run

👍 started the job as gitpod-build-at-session-fix.3

@jankeromnes
Copy link
Copy Markdown
Contributor

jankeromnes commented Sep 25, 2020

I tried this, but not sure if relevant:

  1. Log in via GitHub
  2. Go to Access Control
  3. Click on "Connect" for GitLab

Result:

Screenshot 2020-09-25 at 16 51 11

Note: Using Firefox Nightly as my browser.

@jankeromnes
Copy link
Copy Markdown
Contributor

Update: Doing the same thing in Chrome works:

Screenshot 2020-09-25 at 16 53 52

@jankeromnes
Copy link
Copy Markdown
Contributor

Maybe this is because we use insecure HTTP deployments while we should be using HTTPS instead?

@AlexTugarev
Copy link
Copy Markdown
Member Author

AlexTugarev commented Oct 1, 2020

/werft run

👍 started the job as gitpod-build-at-session-fix.4

@AlexTugarev
Copy link
Copy Markdown
Member Author

Note: Using Firefox Nightly as my browser.

@jankeromnes does it also fail with regular FF?

@svenefftinge
Copy link
Copy Markdown
Contributor

svenefftinge commented Oct 5, 2020

/werft run

👍 started the job as gitpod-build-at-session-fix.5

@hm2075
Copy link
Copy Markdown

hm2075 commented Oct 6, 2020

build failing?

@csweichel
Copy link
Copy Markdown
Contributor

csweichel commented Oct 7, 2020

/werft run

👍 started the job as gitpod-build-at-session-fix.6

@hm2075
Copy link
Copy Markdown

hm2075 commented Oct 12, 2020

can i request for this to be bumped up?

@AlexTugarev
Copy link
Copy Markdown
Member Author

AlexTugarev commented Oct 12, 2020

/werft run

👍 started the job as gitpod-build-at-session-fix.7

@hm2075
Copy link
Copy Markdown

hm2075 commented Oct 12, 2020

tested this

image

would that happen because my instance is behind a corporate firewall?

@AlexTugarev
Copy link
Copy Markdown
Member Author

@hm2075 thanks for watching this issue!

what exactly did you test? did you deploy the server image from this branch?

would that happen because my instance is behind a corporate firewall?

I have no clue about the setup of your FW.

The OAuth error OTOH looks unrelated to the underlying issue, though. This indeed indicates a broken config, most likely on the auth server side, e.g. wrong return URL or client id/password.

@hm2075
Copy link
Copy Markdown

hm2075 commented Oct 12, 2020

@hm2075 thanks for watching this issue!

what exactly did you test? did you deploy the server image from this branch?

would that happen because my instance is behind a corporate firewall?

I have no clue about the setup of your FW.

The OAuth error OTOH looks unrelated to the underlying issue, though. This indeed indicates a broken config, most likely on the auth server side, e.g. wrong return URL or client id/password.

hi

i just added my local gitlab lab server to http://at-session-fix.staging.gitpod-dev.com/

probably not the best way to test this, however testing with gitlab.com worked fine

I guess i would need to deploy this fix to my local instance to test fully


const hostParts = hostName.split('.');
const baseDomain = hostParts.slice(hostParts.length - 2).join('.');
domain = `.${baseDomain}`;
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 think we need the dot prefixing in all cases, as we want tosend the cookie with requests to subdomains as well, no?

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.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie

cf. Domain

Contrary to earlier specifications, leading dots in domain names (.example.com) are ignored.

Copy link
Copy Markdown
Contributor

@svenefftinge svenefftinge Oct 14, 2020

Choose a reason for hiding this comment

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

then let's remove the dot here as well.

// - google: chromium not sending cookies set with redirect

const hostParts = hostName.split('.');
const baseDomain = hostParts.slice(hostParts.length - 2).join('.');
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 wonder why the slicing and special handling is necessary here. Also in dev staging all the requests should go to the hostname URL. Is that not the case?

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.

exactly. I recall, why this is actually needed. in dev staging preview environments we have the ingress proxy which terminates https connections, which is a crucial part in the login process, right? the URL of the ingress proxy has no namespace prefix at all, that's why we've chosen the sliced version of it. this allows those cookies to be present on ingress proxy requests, which are then forwarded to the services.

@hm2075 hm2075 mentioned this pull request Oct 15, 2020
@AlexTugarev AlexTugarev merged commit 9a03c99 into master Oct 16, 2020
@AlexTugarev AlexTugarev deleted the at/session-fix branch October 16, 2020 12:59
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.

Self hosted gitpod and gitlab Auth issues

5 participants