Skip to content

Add pages unique domain option

Kassio Borges requested to merge kassio/add-pages-unique-domain into master

What does this MR do and why?

Problem

Currently, cookies of different gitlab-pages sites under the same namespace are leaked due to the gitlab-pages default URL format: namespace.gitlab.io/project

Solution

Add an option to enable users to create a unique subdomain for a gitlab-pages project, like: project-namespace-somerandomvalue.gitlab.io

How

based on the PoC !106961 (closed)

  1. Create two columns in the project_settings table:

This way, we can keep the unique domain even if the user disables the feature.

  1. Add a checkbox in namespace/project/pages (Project pages settings) allowing the user to enable the feature (pages_unique_domain_enabled)
    • Use a feature flag to control the checkbox
  2. The unique subdomain can follow a format like: projectpath-namespacepath-randomstring
    • project path: up to 48 chars
    • namespace path: complete value up to 48 chars
    • random string: SecureRandom.hex(size) to fill the value to 63 chars

Examples:

project path namespace path unique domain
project namespace project-namespace-c226671dcc75af60ff0c42aa4b46cdc4704d3b83c302a
pppppppppppppppppppppppppppppppppppppppp (40 chars) namespace pppppppppppppppppppppppppppppppppppppppp-namespa-0f932f0421b616
ppppppppppppppppppppppppppppppppppppppppppppppppp (49 chars) namespace pppppppppppppppppppppppppppppppppppppppppppppppp-dccac2434fcf48

Related to: #388178 (closed)

database migration

Extracted to: !111613 (merged)

Screenshots or screen recordings

Screen_Recording_2023-01-16_at_19.42.00

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Kassio Borges

Merge request reports