diff options
author | Vladimir Shushlin <vshushlin@gitlab.com> | 2019-06-06 18:55:31 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-06-06 18:55:31 +0000 |
commit | c3338c920d6123174000ea11243cb7dc285cee03 (patch) | |
tree | 018ca45fb1ce2b02f9a513321c05fc7a4440abce /app/models | |
parent | 68a1ba6a296f340fcddf58e5fbd26d51d66bd90b (diff) | |
download | gitlab-ce-c3338c920d6123174000ea11243cb7dc285cee03.tar.gz |
Add pages domains acme orders
Extract acme double to helper
Create ACME challanges for pages domains
* Create order & challange through API
* save them to database
* request challenge validation
We're saving order and challenge as one entity,
that wouldn't be correct if we would order certificates for
several domains simultaneously, but we always order certificate
per domain
Add controller for processing acme challenges redirected from pages
Don't save acme challenge url - we don't use it
Validate acme challenge attributes
Encrypt private_key in acme orders
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/pages_domain.rb | 1 | ||||
-rw-r--r-- | app/models/pages_domain_acme_order.rb | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/app/models/pages_domain.rb b/app/models/pages_domain.rb index 407d85b1520..5c3441791fd 100644 --- a/app/models/pages_domain.rb +++ b/app/models/pages_domain.rb @@ -5,6 +5,7 @@ class PagesDomain < ApplicationRecord VERIFICATION_THRESHOLD = 3.days.freeze belongs_to :project + has_many :acme_orders, class_name: "PagesDomainAcmeOrder" validates :domain, hostname: { allow_numeric_hostname: true } validates :domain, uniqueness: { case_sensitive: false } diff --git a/app/models/pages_domain_acme_order.rb b/app/models/pages_domain_acme_order.rb new file mode 100644 index 00000000000..63d7fbc8206 --- /dev/null +++ b/app/models/pages_domain_acme_order.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class PagesDomainAcmeOrder < ApplicationRecord + belongs_to :pages_domain + + scope :expired, -> { where("expires_at < ?", Time.now) } + + validates :pages_domain, presence: true + validates :expires_at, presence: true + validates :url, presence: true + validates :challenge_token, presence: true + validates :challenge_file_content, presence: true + validates :private_key, presence: true + + attr_encrypted :private_key, + mode: :per_attribute_iv, + key: Settings.attr_encrypted_db_key_base_truncated, + algorithm: 'aes-256-gcm', + encode: true + + def self.find_by_domain_and_token(domain_name, challenge_token) + joins(:pages_domain).find_by(pages_domains: { domain: domain_name }, challenge_token: challenge_token) + end +end |