conjur-asset-layer-api 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2508286ad920028ad7ff4b1ebf42157e04e1a723
4
- data.tar.gz: 03a85126384297b4701bdafa56f03742d2497d89
3
+ metadata.gz: 2e93a7c855bdc715040ff6e0bfbb3438446a3868
4
+ data.tar.gz: 66b7b240115a76f615adf87574a41db86037704b
5
5
  SHA512:
6
- metadata.gz: 79d9651c0c2b4f6cedd334ae40bd55fffc8ba67af75b73069e3e77eea4ac1fc2c85e71f7adf6b2222e58bb6b6cf72172e20f89de41c4597ac491f78997a1552d
7
- data.tar.gz: 23e4a963dd008f2a4ebd706158100abe3a3769b3aec03a034417e9b32b6bce38107448acccb552a3a335dd5113899d0d96619f807ceef367bc3c28526f9efc17
6
+ metadata.gz: c6e711a6bc92e4da9581bc1bc262ad2b426ce55e193e9ecb101207e62901c23fc5139e287c92b277cd4b7ece73357951159ff5d0a97d50e02ff1e508469f4667
7
+ data.tar.gz: 89be42ae54025c6981f3349939452bd452137f6c14c4e1dd78aa82931889c3d76397f8fd73ab7e2c1be97f8f75d8df6c16dd5650d9b8de9f03eebf30bdf8c44c
@@ -1,7 +1,7 @@
1
1
  module Conjur
2
2
  module Asset
3
3
  module Layer
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
6
6
  end
7
7
  end
@@ -12,6 +12,26 @@ class Conjur::Command::Layers < Conjur::Command
12
12
  end
13
13
  hostid
14
14
  end
15
+
16
+ def self.interpret_layer_privilege(privilege)
17
+ case privilege
18
+ when 'execute'
19
+ 'use_host'
20
+ when 'update'
21
+ 'admin_host'
22
+ else
23
+ exit_now! "Invalid privilege '#{privilege}'. Acceptable values are : execute, update"
24
+ end
25
+ end
26
+
27
+ def self.parse_layer_permission_args(global_options, options, args)
28
+ id = require_arg(args, "layer")
29
+ role = require_arg(args, "role")
30
+ privilege = require_arg(args, "privilege")
31
+ role_name = interpret_layer_privilege privilege
32
+ [ id, role_name, role ]
33
+ end
34
+
15
35
 
16
36
  desc "Create a new layer"
17
37
  arg_name "id"
@@ -92,6 +112,43 @@ class Conjur::Command::Layers < Conjur::Command
92
112
  puts "Layer provisioned by #{provisioner}"
93
113
  end
94
114
  end
115
+
116
+ desc "Permit a privilege on hosts in the layer"
117
+ long_desc <<-DESC
118
+ Privilege may be : execute, update
119
+ DESC
120
+ arg_name "layer role privilege"
121
+ command :"hosts:permit" do |c|
122
+ c.action do |global_options,options,args|
123
+ id, role_name, role = parse_layer_permission_args(global_options, options, args)
124
+ api.layer(id).add_member role_name, role
125
+ puts "Permission granted"
126
+ end
127
+ end
128
+
129
+ desc "Remove a privilege on hosts in the layer"
130
+ arg_name "layer role privilege"
131
+ command :"hosts:deny" do |c|
132
+ c.action do |global_options,options,args|
133
+ id, role_name, role = parse_layer_permission_args(global_options, options, args)
134
+ api.layer(id).remove_member role_name, role
135
+ puts "Permission removed"
136
+ end
137
+ end
138
+
139
+ desc "List roles that have permission on the hosts"
140
+ arg_name "layer privilege"
141
+ command :"hosts:permitted_roles" do |c|
142
+ c.action do |global_options,options,args|
143
+ id = require_arg(args, "layer")
144
+ role_name = interpret_layer_privilege require_arg(args, "privilege")
145
+
146
+ members = api.layer(id).hosts_members(role_name).map(&:member).select do |m|
147
+ m.kind != "@"
148
+ end
149
+ display members.map(&:roleid)
150
+ end
151
+ end
95
152
 
96
153
  desc "Add a host to an layer"
97
154
  arg_name "layer host"
@@ -22,6 +22,11 @@ module Conjur
22
22
  RestClient::Resource.new(self["hosts/#{fully_escape hostid}"].url, options).delete
23
23
  end
24
24
  end
25
+
26
+ # Lists the roles that have been granted access to the hosts owned roles.
27
+ def hosts_members(role_name)
28
+ owned_role(role_name).members
29
+ end
25
30
 
26
31
  def hosts
27
32
  self.attributes['hosts'].collect do |id|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conjur-asset-layer-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Gilpin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-02 00:00:00.000000000 Z
11
+ date: 2014-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: conjur-api