Skip to content

Newline in `smtp-pass` secret causes mail to fail

Summary

A newline character in the smtp-pass secret causes mail to fail with an authentication failure. Could we do something to trim newlines in "password" secrets?

Steps to reproduce

Add a kubernetes secret for a password that contains a newline. Deploy GitLab with the chart and authentication with that secret will fail due to the newline (at least in the smtp-pass secret).

Configuration used

smtp:
  enabled: true
  address: HOSTNAME
  port: 587
  user_name: "USERNAME"
  password:
    secret: gitlab-external-secrets
    key: smtp-pass
  domain: 'example.com'
  authentication: "login"
  starttls_auto: true
  openssl_verify_mode: "none"

Relevant logs

2019-01-07T10:58:41.026Z 10 TID-goj08lwoq WARN: Net::SMTPAuthenticationError: 535 5.7.8 Error: authentication failed: UGFzc3dvcmQ6
2019-01-07T10:58:41.026Z 10 TID-goj08lwoq WARN: /usr/lib/ruby/2.4.0/net/smtp.rb:981:in `check_auth_response'
/usr/lib/ruby/2.4.0/net/smtp.rb:747:in `auth_login'
/usr/lib/ruby/2.4.0/net/smtp.rb:728:in `authenticate'
/usr/lib/ruby/2.4.0/net/smtp.rb:565:in `do_start'
/usr/lib/ruby/2.4.0/net/smtp.rb:518:in `start'