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
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/deploy_token.rb')
-rw-r--r--app/models/deploy_token.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/app/models/deploy_token.rb b/app/models/deploy_token.rb
index 920321a1699..60ecdf6c367 100644
--- a/app/models/deploy_token.rb
+++ b/app/models/deploy_token.rb
@@ -6,12 +6,12 @@ class DeployToken < ApplicationRecord
include PolicyActor
include Gitlab::Utils::StrongMemoize
- add_authentication_token_field :token, encrypted: :required
-
AVAILABLE_SCOPES = %i[read_repository read_registry write_registry
read_package_registry write_package_registry].freeze
GITLAB_DEPLOY_TOKEN_NAME = 'gitlab-deploy-token'
- REQUIRED_DEPENDENCY_PROXY_SCOPES = %i[read_registry write_registry].freeze
+ DEPLOY_TOKEN_PREFIX = 'gldt-'
+
+ add_authentication_token_field :token, encrypted: :required, format_with_prefix: :prefix_for_deploy_token
attribute :expires_at, default: -> { Forever.date }
@@ -57,7 +57,7 @@ class DeployToken < ApplicationRecord
def valid_for_dependency_proxy?
group_type? &&
active? &&
- REQUIRED_DEPENDENCY_PROXY_SCOPES.all? { |scope| scope.in?(scopes) }
+ (Gitlab::Auth::REGISTRY_SCOPES & scopes).size == Gitlab::Auth::REGISTRY_SCOPES.size
end
def revoke!
@@ -141,6 +141,10 @@ class DeployToken < ApplicationRecord
write_attribute(:expires_at, value.presence || Forever.date)
end
+ def prefix_for_deploy_token
+ DEPLOY_TOKEN_PREFIX
+ end
+
private
def expired?