diff options
Diffstat (limited to 'app/models/project.rb')
-rw-r--r-- | app/models/project.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 512c6ac1acb..de7dd42866f 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -89,6 +89,11 @@ 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 @@ -109,7 +114,9 @@ class Project < ApplicationRecord default_value_for :autoclose_referenced_issues, true default_value_for(:ci_config_path) { Gitlab::CurrentSettings.default_ci_config_path } - add_authentication_token_field :runners_token, encrypted: -> { Feature.enabled?(:projects_tokens_optional_encryption, default_enabled: true) ? :optional : :required } + add_authentication_token_field :runners_token, + encrypted: -> { Feature.enabled?(:projects_tokens_optional_encryption, default_enabled: true) ? :optional : :required }, + prefix: ->(instance) { instance.runners_token_prefix } before_validation :mark_remote_mirrors_for_removal, if: -> { RemoteMirror.table_exists? } @@ -1873,6 +1880,15 @@ class Project < ApplicationRecord ensure_runners_token! end + def runners_token_prefix + Feature.enabled?(:projects_runners_token_prefix, self, default_enabled: :yaml) ? RUNNERS_TOKEN_PREFIX : '' + end + + override :format_runners_token + def format_runners_token(token) + "#{runners_token_prefix}#{token}" + end + def pages_deployed? pages_metadatum&.deployed? end |