summaryrefslogtreecommitdiff
path: root/lib/gitlab/lets_encrypt.rb
diff options
context:
space:
mode:
authorVladimir Shushlin <v.shushlin@gmail.com>2019-06-13 14:37:45 +0300
committerVladimir Shushlin <v.shushlin@gmail.com>2019-06-25 10:30:12 +0200
commit432f2bbc9cf64d53418c1eb9bb701254803a0e1e (patch)
tree6f93c0b6ecafcdcf7ca7f76d48b7a5afa2319204 /lib/gitlab/lets_encrypt.rb
parent3115c9fc121743dea29aa92a603a0c782eb3d75b (diff)
downloadgitlab-ce-432f2bbc9cf64d53418c1eb9bb701254803a0e1e.tar.gz
Use project depended feature flag for pages sslpages-ssl-project-aware-feature-flag
Also add ::Gitlab::LetsEncrypt.enabled? shortcut and simplify it a lot
Diffstat (limited to 'lib/gitlab/lets_encrypt.rb')
-rw-r--r--lib/gitlab/lets_encrypt.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/gitlab/lets_encrypt.rb b/lib/gitlab/lets_encrypt.rb
new file mode 100644
index 00000000000..cdf24f24647
--- /dev/null
+++ b/lib/gitlab/lets_encrypt.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module LetsEncrypt
+ def self.enabled?(pages_domain = nil)
+ return false unless Gitlab::CurrentSettings.lets_encrypt_terms_of_service_accepted
+
+ return false unless Feature.enabled?(:pages_auto_ssl)
+
+ # If no domain is passed, just check whether we're enabled globally
+ return true unless pages_domain
+
+ !!pages_domain.project && Feature.enabled?(:pages_auto_ssl_for_project, pages_domain.project)
+ end
+ end
+end