Class: Conjur::Policy::Executor::Grant

Inherits:
Base show all
Defined in:
lib/conjur/policy/executor/grant.rb

Instance Attribute Summary

Attributes inherited from Base

#actions, #api, #statement

Instance Method Summary collapse

Methods inherited from Base

#action, #initialize, #resource_path, #role_path

Methods included from Logger

included

Constructor Details

This class inherits a constructor from Conjur::Policy::Executor::Base

Instance Method Details

#add_host_to_layerObject



11
12
13
14
15
16
17
18
# File 'lib/conjur/policy/executor/grant.rb', line 11

def add_host_to_layer
  parameters = { "hostid" => statement.member.role.roleid }
  action({
    'method' => 'post',
    'path' => "layers/#{fully_escape statement.role.id}/hosts",
    'parameters' => parameters
  })
end

#executeObject



3
4
5
6
7
8
9
# File 'lib/conjur/policy/executor/grant.rb', line 3

def execute
  if statement.role.is_a?(Conjur::Policy::Types::Layer) && statement.member.role.is_a?(Conjur::Policy::Types::Host)
    add_host_to_layer
  else
    grant_role_to_member
  end
end

#grant_role_to_memberObject



20
21
22
23
24
25
26
27
28
# File 'lib/conjur/policy/executor/grant.rb', line 20

def grant_role_to_member
  parameters = { "member" => statement.member.role.roleid }
  parameters['admin_option'] = statement.member.admin unless statement.member.admin.nil?
  action({
    'method' => 'put',
    'path' => "authz/#{statement.role.}/roles/#{statement.role.role_kind}/#{statement.role.id}?members",
    'parameters' => parameters
  })
end