Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/email/smtp_config.rb')
-rw-r--r--lib/gitlab/email/smtp_config.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/gitlab/email/smtp_config.rb b/lib/gitlab/email/smtp_config.rb
new file mode 100644
index 00000000000..c9deb3fe324
--- /dev/null
+++ b/lib/gitlab/email/smtp_config.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Email
+ class SmtpConfig
+ def self.encrypted_secrets
+ Settings.encrypted(Gitlab.config.gitlab.email_smtp_secret_file)
+ end
+
+ def self.secrets
+ self.new
+ end
+
+ def initialize
+ @secrets ||= self.class.encrypted_secrets.config
+ rescue StandardError => e
+ Gitlab::AppLogger.error "SMTP encrypted secrets are invalid: #{e.inspect}"
+ end
+
+ def username
+ @secrets&.fetch(:user_name, nil)&.chomp
+ end
+
+ def password
+ @secrets&.fetch(:password, nil)&.chomp
+ end
+ end
+ end
+end