Class: Gitlab::GitAccessSnippet

Inherits:
GitAccess show all
Extended by:
Utils::Override
Defined in:
lib/gitlab/git_access_snippet.rb

Constant Summary collapse

ERROR_MESSAGES =
{
  authentication_mechanism: 'The authentication mechanism is not supported.',
  read_snippet: 'You are not allowed to read this snippet.',
  update_snippet: 'You are not allowed to update this snippet.',
  snippet_not_found: 'The snippet you were looking for could not be found.',
  no_repo: 'The snippet repository you were looking for could not be found.'
}.freeze

Constants inherited from GitAccess

Gitlab::GitAccess::ALL_COMMANDS, Gitlab::GitAccess::ANY, Gitlab::GitAccess::DOWNLOAD_COMMANDS, Gitlab::GitAccess::ForbiddenError, Gitlab::GitAccess::INTERNAL_TIMEOUT, Gitlab::GitAccess::LOG_HEADER, Gitlab::GitAccess::NotFoundError, Gitlab::GitAccess::PUSH_COMMANDS, Gitlab::GitAccess::ProjectMovedError, Gitlab::GitAccess::TimeoutError

Instance Attribute Summary

Attributes inherited from GitAccess

#actor, #auth_result_type, #authentication_abilities, #changes, #cmd, #container, #namespace_path, #protocol, #redirected_path

Instance Method Summary collapse

Methods included from Utils::Override

extended, extensions, included, method_added, override, prepended, queue_verification, verify!

Methods inherited from GitAccess

#build_can_download_code?, #deploy_key_can_download_code?, #guest_can_download_code?, #logger, #protocol_allowed?, #repository_path, #request_from_ci_build?, #user_can_download_code?

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(actor, snippet, protocol, **kwargs) ⇒ GitAccessSnippet

Returns a new instance of GitAccessSnippet.


17
18
19
20
21
22
# File 'lib/gitlab/git_access_snippet.rb', line 17

def initialize(actor, snippet, protocol, **kwargs)
  super(actor, snippet, protocol, **kwargs)

  @auth_result_type = nil
  @authentication_abilities &= [:download_code, :push_code]
end

Instance Method Details

#check(cmd, changes) ⇒ Object


25
26
27
28
29
# File 'lib/gitlab/git_access_snippet.rb', line 25

def check(cmd, changes)
  check_snippet_accessibility!

  super
end

#download_abilityObject


32
33
34
# File 'lib/gitlab/git_access_snippet.rb', line 32

def download_ability
  :read_snippet
end

#push_abilityObject


37
38
39
# File 'lib/gitlab/git_access_snippet.rb', line 37

def push_ability
  :update_snippet
end