Add Configuration Option for Mandatory public email

Problem to solve

Since https://gitlab.com/gitlab-org/gitlab-ce/issues/57253 we've decoupled public_email from email out of security concerns. However, some enterprise customers would like to enforce that everybody has a public email or, that everybody's corporate email is public.

Target audience

Proposal

Introduce an instance level setting that, when selected by admins, uses each user's primary email address as their public email address.

Implementation plan

  1. Create a migration to add a column enforce_public_email in application_settings (something like db/migrate/20250416144638_add_project_web_based_commit_signing_enabled_setting.rb)
  2. Add the field to visible_attributes in app/helpers/application_settings_helper.rb
  3. Add the new field to app/views/admin/application_settings/_account_and_limit.html.haml (I think this is most logical place on admin -> settings -> general -> account and limit)
  4. Expose lib/api/entities/application_setting.rb
  5. Allow updating via the API lib/api/settings.rb

This can (and should be) broken up into multiple merge requests- perhaps:

  1. Add the database column
  2. Add to the UI
  3. Add to the API

ZD https://gitlab.zendesk.com/agent/tickets/113781 (internal)

Edited by 🤖 GitLab Bot 🤖