Skip to content

Add initial setup to configure root account email and password

Andrew Evans requested to merge 211722-default-admin-email-improvement into master

What does this MR do and why?

Currently, when GitLab is first installed and set up regardless of method, the default admin user root likely has the known email address admin@example.com . This makes it easier to exploit if there is an email-based vulnerability.

To encourage admins to change this email address, we add a new screen which appears on first sign-in for a fresh install with fields for the root account email and password. This bypasses many of the normal checks for users changing email and password (requiring login, requiring email confirmation, etc). It does not get around password length or complexity rules, and does validate that the email address matches the expected format.

This MR also adds some slight randomization to the initial admin email address, so it is hard to guess while pending initial setup.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After
Screenshot_2024-05-01_at_10.23.44_AM

How to set up and validate locally

  1. Check out the branch
  2. mv db/fixtures/development db/fixtures/development-bkp
  3. mv db/fixtures/production db/fixtures/development (this ensures reset-data produces a "fresh install" state, instead of the pre-populated instance that development fixtures normally introduce)
  4. gdk reset-data (this will nuke all data for your local gdk)
  5. navigate to your gdk instance: https://gdk.test:3443
  6. you should be directed to the initial setup screen

Database Review

This MR adds deletes non-primary emails after the root user's email is changed, in order to clean up the email address initially assigned during installation. I don't anticipate any scaling issues, since this is only for self-managed, and can only happen when there is a single user in the database, and likely exactly two rows in the emails table.

Analysis link

explain DELETE FROM "emails" WHERE "emails"."id" = 28

 ModifyTable on public.emails  (cost=0.43..3.45 rows=0 width=0) (actual time=8.758..8.759 rows=0 loops=1)  
   Buffers: shared hit=3 read=8 dirtied=2  
   I/O Timings: read=8.494 write=0.000  
   ->  Index Scan using emails_pkey on public.emails  (cost=0.43..3.45 rows=1 width=6) (actual time=4.533..4.536 rows=1 loops=1)  
         Index Cond: (emails.id = 28)  
         Buffers: shared read=4  

Related to #211722 and #458985 (closed)

Edited by Andrew Evans

Merge request reports