Module: Gitlab::Pages

Includes:
JwtAuthenticatable
Defined in:
lib/gitlab/pages.rb,
lib/gitlab/pages/settings.rb,
lib/gitlab/pages/url_builder.rb,
lib/gitlab/pages/random_domain.rb,
lib/gitlab/pages/virtual_host_finder.rb,
lib/gitlab/pages/deployment_validations.rb

Defined Under Namespace

Classes: DeploymentValidations, RandomDomain, Settings, UniqueDomainGenerationFailure, UrlBuilder, VirtualHostFinder

Constant Summary collapse

VERSION =
File.read(Rails.root.join("GITLAB_PAGES_VERSION")).strip.freeze
INTERNAL_API_REQUEST_HEADER =
'Gitlab-Pages-Api-Request'
MAX_SIZE =
1.terabyte
DEPLOYMENT_EXPIRATION =
24.hours

Constants included from JwtAuthenticatable

JwtAuthenticatable::SECRET_LENGTH

Class Method Summary collapse

Methods included from JwtAuthenticatable

included

Class Method Details

.access_control_is_forced?Boolean

Returns:

  • (Boolean)


29
30
31
32
# File 'lib/gitlab/pages.rb', line 29

def access_control_is_forced?
  ::Gitlab.config.pages.access_control &&
    ::Gitlab::CurrentSettings.current_application_settings.force_pages_access_control
end

.add_unique_domain_to(project) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/gitlab/pages.rb', line 38

def add_unique_domain_to(project)
  return unless enabled?
  # If the project used a unique domain once, it'll always use the same
  return if project.project_setting.pages_unique_domain_in_database.present?

  project.project_setting.pages_unique_domain_enabled = true
  project.project_setting.pages_unique_domain = generate_unique_domain(project)
end

.enabled?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/gitlab/pages.rb', line 34

def enabled?
  Gitlab.config.pages.enabled
end

.multiple_versions_enabled_for?(project) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
50
51
52
# File 'lib/gitlab/pages.rb', line 47

def multiple_versions_enabled_for?(project)
  return false if project.blank?

  ::Feature.enabled?(:pages_multiple_versions_setting, project) &&
    project.licensed_feature_available?(:pages_multiple_versions)
end

.secret_pathObject



25
26
27
# File 'lib/gitlab/pages.rb', line 25

def secret_path
  Gitlab.config.pages.secret_file
end

.verify_api_request(request_headers) ⇒ Object



19
20
21
22
23
# File 'lib/gitlab/pages.rb', line 19

def verify_api_request(request_headers)
  decode_jwt(request_headers[INTERNAL_API_REQUEST_HEADER], issuer: 'gitlab-pages')
rescue JWT::DecodeError
  false
end