Skip to content

Commit c95365c

Browse files
committed
Sync config v14.2.0 : gitlab: Add commented-out config for encrypted SMTP credentials
See corresponding MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/67802
1 parent 872a6b7 commit c95365c

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

assets/runtime/config/gitlabhq/gitlab.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,12 @@ production: &base
123123
# ca_certs_file: /home/git/gitlab/.gitlab_smime_ca_certs
124124

125125
# Email server smtp settings are in config/initializers/smtp_settings.rb.sample
126+
# File location to read encrypted SMTP secrets from
127+
# email_smtp_secret_file: /mnt/gitlab/smtp.yaml.enc # Default: shared/encrypted_settings/smtp.yaml.enc
126128

127129
default_projects_limit: {{GITLAB_PROJECTS_LIMIT}}
128130
default_can_create_group: {{GITLAB_CREATE_GROUP}} # default: true
129131
username_changing_enabled: {{GITLAB_USERNAME_CHANGE}} # default: true - User can change their username/namespace
130-
signup_enabled: {{GITLAB_SIGNUP_ENABLED}}
131132
## Default theme ID
132133
## 1 - Indigo
133134
## 2 - Dark

assets/runtime/config/gitlabhq/smtp_settings.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@
99

1010
if Rails.env.production?
1111
Rails.application.config.action_mailer.delivery_method = :smtp
12+
secrets = Gitlab::Email::SmtpConfig.secrets
1213

1314
ActionMailer::Base.delivery_method = :smtp
1415
ActionMailer::Base.smtp_settings = {
1516
address: "{{SMTP_HOST}}",
1617
port: {{SMTP_PORT}},
1718
user_name: "{{SMTP_USER}}",
1819
password: "{{SMTP_PASS}}",
20+
## If you are using encrypted smtp credentials then you should instead use the secrets user_name/password
21+
## See: https://docs.gitlab.com/ee/administration/raketasks/smtp.html#secrets
22+
# user_name: secrets.username,
23+
# password: secrets.password,
1924
domain: "{{SMTP_DOMAIN}}",
2025
authentication: "{{SMTP_AUTHENTICATION}}",
2126
enable_starttls_auto: {{SMTP_STARTTLS}},
@@ -34,6 +39,7 @@
3439
#
3540
# if Rails.env.production?
3641
# Rails.application.config.action_mailer.delivery_method = :smtp_pool
42+
# secrets = Gitlab::Email::SmtpConfig.secrets
3743
#
3844
# ActionMailer::Base.delivery_method = :smtp_pool
3945
# ActionMailer::Base.smtp_pool_settings = {
@@ -43,6 +49,10 @@
4349
# port: 465,
4450
# user_name: "smtp",
4551
# password: "123456",
52+
# ## If you are using encrypted smtp credentials then you should instead use the secrets user_name/password
53+
# ## See: https://docs.gitlab.com/ee/administration/raketasks/smtp.html#secrets
54+
# # user_name: secrets.username,
55+
# # password: secrets.password,
4656
# domain: "gitlab.company.com",
4757
# authentication: :login,
4858
# enable_starttls_auto: true,

assets/runtime/functions

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1843,7 +1843,6 @@ configure_gitlab() {
18431843
GITLAB_SSH_HOST \
18441844
GITLAB_SSH_LISTEN_PORT \
18451845
GITLAB_SSH_PORT \
1846-
GITLAB_SIGNUP_ENABLED \
18471846
GITLAB_IMPERSONATION_ENABLED \
18481847
GITLAB_PROJECTS_LIMIT \
18491848
GITLAB_USERNAME_CHANGE \
@@ -1887,6 +1886,15 @@ configure_gitlab() {
18871886
generate_healthcheck_script
18881887
gitlab_configure_content_security_policy
18891888

1889+
# some configurations are stored in database
1890+
## GITLAB_SIGNUP_ENABLED : `signup_enabled` in `application_settings` table
1891+
## avoid injection: set to false unless explicitly specified to be true
1892+
if [[ "${GITLAB_SIGNUP_ENABLED}" != true ]]; then
1893+
GITLAB_SIGNUP_ENABLED=false
1894+
fi
1895+
printf "Configurating application_settings.signup_enabled=%s :" ${GITLAB_SIGNUP_ENABLED}
1896+
PGPASSWORD="${DB_PASS}" psql -h "${DB_HOST}" -p "${DB_PORT}" -U "${DB_USER}" -d "${DB_NAME}" -Atw -c "UPDATE application_settings SET signup_enabled = ${GITLAB_SIGNUP_ENABLED}"
1897+
18901898
# remove stale gitlab.socket
18911899
rm -rf ${GITLAB_INSTALL_DIR}/tmp/sockets/gitlab.socket
18921900
}

0 commit comments

Comments
 (0)