Skip to content

Set different session cookie for Geo secondaries

Catalin Irimie requested to merge cat-different-cookie-geo into master

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)

  1. Two Omnibus instances (or GDKs configured as 'production' env) with Geo set up.
  2. Access the secondary Geo instance to see the cookie name be different

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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
Edited by Michael Kozono

Merge request reports