Add pages unique domain
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)
- Create two columns in the
project_settings
table:-
pages_unique_domain
(text): where the unique domain will be stored. (limit of 63 chars - https://www.freesoft.org/CIE/RFC/1035/9.htm) -
pages_unique_domain_enabled
(bool): if the unique domain feature is enabled
-
This way, we can keep the unique domain even if the user disables the feature.
- 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
- 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 |
Edited by Kassio Borges