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
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/models/concerns/runners_token_prefixable.rb14
-rw-r--r--app/models/group.rb12
-rw-r--r--app/models/project.rb10
3 files changed, 19 insertions, 17 deletions
diff --git a/app/models/concerns/runners_token_prefixable.rb b/app/models/concerns/runners_token_prefixable.rb
new file mode 100644
index 00000000000..1aea874337e
--- /dev/null
+++ b/app/models/concerns/runners_token_prefixable.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+module RunnersTokenPrefixable
+ extend ActiveSupport::Concern
+
+ # Prefix for runners_token which can be used to invalidate existing tokens.
+ # The value chosen here is GR (for Gitlab Runner) combined with the rotation
+ # date (20220225) decimal to hex encoded.
+ RUNNERS_TOKEN_PREFIX = 'GR1348941'
+
+ def runners_token_prefix
+ RUNNERS_TOKEN_PREFIX
+ end
+end
diff --git a/app/models/group.rb b/app/models/group.rb
index a395861fbb6..1d6a3a14450 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -19,14 +19,10 @@ class Group < Namespace
include BulkMemberAccessLoad
include ChronicDurationAttribute
include RunnerTokenExpirationInterval
+ include RunnersTokenPrefixable
extend ::Gitlab::Utils::Override
- # Prefix for runners_token which can be used to invalidate existing tokens.
- # The value chosen here is GR (for Gitlab Runner) combined with the rotation
- # date (20220225) decimal to hex encoded.
- RUNNERS_TOKEN_PREFIX = 'GR1348941'
-
def self.sti_name
'Group'
end
@@ -124,7 +120,7 @@ class Group < Namespace
add_authentication_token_field :runners_token,
encrypted: -> { Feature.enabled?(:groups_tokens_optional_encryption, default_enabled: true) ? :optional : :required },
- prefix: ->(instance) { instance.runners_token_prefix }
+ prefix: RunnersTokenPrefixable::RUNNERS_TOKEN_PREFIX
after_create :post_create_hook
after_destroy :post_destroy_hook
@@ -678,10 +674,6 @@ class Group < Namespace
ensure_runners_token!
end
- def runners_token_prefix
- Feature.enabled?(:groups_runners_token_prefix, self, default_enabled: :yaml) ? RUNNERS_TOKEN_PREFIX : ''
- end
-
override :format_runners_token
def format_runners_token(token)
"#{runners_token_prefix}#{token}"
diff --git a/app/models/project.rb b/app/models/project.rb
index de7dd42866f..f89e616a5ca 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -38,6 +38,7 @@ class Project < ApplicationRecord
include GitlabRoutingHelper
include BulkMemberAccessLoad
include RunnerTokenExpirationInterval
+ include RunnersTokenPrefixable
extend Gitlab::Cache::RequestCache
extend Gitlab::Utils::Override
@@ -89,11 +90,6 @@ class Project < ApplicationRecord
DEFAULT_SQUASH_COMMIT_TEMPLATE = '%{title}'
- # Prefix for runners_token which can be used to invalidate existing tokens.
- # The value chosen here is GR (for Gitlab Runner) combined with the rotation
- # date (20220225) decimal to hex encoded.
- RUNNERS_TOKEN_PREFIX = 'GR1348941'
-
cache_markdown_field :description, pipeline: :description
default_value_for :packages_enabled, true
@@ -116,7 +112,7 @@ class Project < ApplicationRecord
add_authentication_token_field :runners_token,
encrypted: -> { Feature.enabled?(:projects_tokens_optional_encryption, default_enabled: true) ? :optional : :required },
- prefix: ->(instance) { instance.runners_token_prefix }
+ prefix: RunnersTokenPrefixable::RUNNERS_TOKEN_PREFIX
before_validation :mark_remote_mirrors_for_removal, if: -> { RemoteMirror.table_exists? }
@@ -1881,7 +1877,7 @@ class Project < ApplicationRecord
end
def runners_token_prefix
- Feature.enabled?(:projects_runners_token_prefix, self, default_enabled: :yaml) ? RUNNERS_TOKEN_PREFIX : ''
+ RUNNERS_TOKEN_PREFIX
end
override :format_runners_token