Class: Clusters::Agents::AuthorizeProxyUserService

Inherits:
BaseService
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/clusters/agents/authorize_proxy_user_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#params, #project

Instance Method Summary collapse

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(current_user, agent) ⇒ AuthorizeProxyUserService

Returns a new instance of AuthorizeProxyUserService.



8
9
10
11
# File 'app/services/clusters/agents/authorize_proxy_user_service.rb', line 8

def initialize(current_user, agent)
  @current_user = current_user
  @agent = agent
end

Instance Method Details

#executeObject



13
14
15
16
17
18
19
20
21
22
# File 'app/services/clusters/agents/authorize_proxy_user_service.rb', line 13

def execute
  return forbidden('`user_access` keyword is not found in agent config file.') unless user_access_config.present?

  access_as = user_access_config['access_as']

  return forbidden('`access_as` is not found under the `user_access` keyword.') unless access_as.present?
  return forbidden('`access_as` must exist only once under the `user_access` keyword.') if access_as.size != 1

  handle_access(access_as)
end