Set different session cookie for Geo secondaries
What does this MR do?
To support the secondary proxying the primary while also serving and doing authentication on the secondary itself, the sites need to have different session cookies in order to not overwrite each other.
As the primary site and the secondary site don't share the same session state, when the cookie used on one site, is used with the exact same name on the other site, it overwrites the content, effectively logging out each other.
The effect when upgrading existing Geo setups would be that secondaries would trigger authentication (the OAuth flow) again for the new session, as there's no existing cookie, but this should happen automatically (and also happens periodically without this change) as the user gets redirected back and forth for the auth to happen.
Related to #340086 (closed)
Screenshots or Screencasts (strongly suggested)
Local GDK - unchanged
╰─>$ curl gdk.test:3000/users/sign_in -is | grep _gitlab_session
Set-Cookie: _gitlab_session_9bf4b57a9a04f294c5a05aaa998d022a58c23d173249226934785e46f57c4d32=aa2cd9fa3aeba88c26df147bf26d8027; path=/; expires=Wed, 08 Sep 2021 12:26:07 GMT; HttpOnly
Omnibus instance (Geo primary) - unchanged
╰─>$ curl primary.cattest/users/sign_in -is | grep _gitlab_session
set-cookie: _gitlab_session=eb8b24e9df519b4f6b48e642bb456ea1; path=/; expires=Wed, 08 Sep 2021 12:26:57 GMT; HttpOnly
Omnibus instance (Geo secondary)
╰─>$ curl secondary.cattest/users/sign_in -is | grep _gitlab_session
set-cookie: _gitlab_session_geo_9d4c0bb2aaad3ccbcc576642d6510f7a2fbf4ef5725aa8e3a14387d5d0d6db0e=6a2bfb591ae31a1b55a8bde786c46309; path=/; expires=Wed, 08 Sep 2021 12:34:53 GMT; HttpOnly
How to setup and validate locally (strongly suggested)
Not easily testable in the GDK (except, maybe setting the rails env to be production and having two GDKs with Geo set up)
- Two Omnibus instances (or GDKs configured as 'production' env) with Geo set up.
- Access the secondary Geo instance to see the cookie name be different
Does this MR meet the acceptance criteria?
Conformity
-
I have included changelog trailers, or none are needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.) -
I have tested this MR in all supported browsers, or it's not needed. -
I have informed the Infrastructure department of a default or new setting change per definition of done, or it's not needed.
Security
Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team