diff options
author | Nick Thomas <nick@gitlab.com> | 2018-03-23 18:48:28 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-03-23 18:48:28 +0300 |
commit | 457a99c612acf59ec9cc4d0793c53465f914e696 (patch) | |
tree | ca474ece3e4db339d225d9789298ee78051848eb /app/models/project.rb | |
parent | 79dd74db14ffdac34fa2eff0aa26387b29a16cb5 (diff) | |
parent | 9d45951fcaeda4f01a2e4be2480d980a3e7cd37e (diff) |
Merge branch 'pages_force_https' into 'master'
HTTPS only Pages
Closes #28857
See merge request gitlab-org/gitlab-ce!16273
Diffstat (limited to 'app/models/project.rb')
-rw-r--r-- | app/models/project.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index ed5f8b00ba2..6a420663644 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -267,6 +267,7 @@ class Project < ActiveRecord::Base validate :visibility_level_allowed_by_group validate :visibility_level_allowed_as_fork validate :check_wiki_path_conflict + validate :validate_pages_https_only, if: -> { changes.has_key?(:pages_https_only) } validates :repository_storage, presence: true, inclusion: { in: ->(_object) { Gitlab.config.repositories.storages.keys } } @@ -737,6 +738,26 @@ class Project < ActiveRecord::Base end end + def pages_https_only + return false unless Gitlab.config.pages.external_https + + super + end + + def pages_https_only? + return false unless Gitlab.config.pages.external_https + + super + end + + def validate_pages_https_only + return unless pages_https_only? + + unless pages_domains.all?(&:https?) + errors.add(:pages_https_only, "cannot be enabled unless all domains have TLS certificates") + end + end + def to_param if persisted? && errors.include?(:path) path_was |