knife-acl 1.0.3 → 1.0.6

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
- SHA1:
3
- metadata.gz: 7b20c4e70c404b3dfdc0238406b653168047c862
4
- data.tar.gz: 34507d1236c7c0027dc4a774aa252ba0e3f4f34a
2
+ SHA256:
3
+ metadata.gz: e4f68cadaee047256abe5aee79be1d498308446f3cd12df183c86729aee34658
4
+ data.tar.gz: 8dad7041ab472cc69b3f631837738806a9166cd606626e094bd0f0c910bdd209
5
5
  SHA512:
6
- metadata.gz: 0135c44d7e10b6f1614f3f7f00d0dd711f97707ce6f1b69eed057ad7f50e60c4dc5e1e288903ad8e44f060d8660224c58d7e9ab908d0060be0b03be4de524f52
7
- data.tar.gz: b77b9b865d6291356250578edb2c0899d1c57160c3ccab25322dcb6266eea45a030a317fd7961df6770bef2867e77aa47abf6f9e15ebdcc58b8b75eeda9bf984
6
+ metadata.gz: 4d1b1e3fe36d8e5dad61679f3e7843cce5d834e5fbed4d5b232b927fc467fd8e072e9c843535044c581286f44f8ef5404f4e23554882281ebf5fe7baa43064ee
7
+ data.tar.gz: aae13368d33a38e9b3806ae9f60b1dcf67be8bb1d728ea9398573cd3b73252d2004a9d0a0a3ba9c9a0976f152d1bd5c331d0f9a97ad180eeb42b1614e4b411c8
@@ -23,7 +23,7 @@ module OpscodeAcl
23
23
  banner "knife acl add MEMBER_TYPE MEMBER_NAME OBJECT_TYPE OBJECT_NAME PERMS"
24
24
 
25
25
  deps do
26
- require 'chef/knife/acl_base'
26
+ require_relative "acl_base"
27
27
  include OpscodeAcl::AclBase
28
28
  end
29
29
 
@@ -36,7 +36,7 @@ module OpscodeAcl
36
36
  exit 1
37
37
  end
38
38
 
39
- unless %w(client group).include?(member_type)
39
+ unless %w{client group}.include?(member_type)
40
40
  ui.fatal "ERROR: To enforce best practice, knife-acl can only add a client or a group to an ACL."
41
41
  ui.fatal " See the knife-acl README for more information."
42
42
  exit 1
@@ -20,28 +20,28 @@
20
20
  module OpscodeAcl
21
21
  module AclBase
22
22
 
23
- PERM_TYPES = %w(create read update delete grant) unless defined? PERM_TYPES
24
- MEMBER_TYPES = %w(client group user) unless defined? MEMBER_TYPES
25
- OBJECT_TYPES = %w(clients containers cookbooks data environments groups nodes roles policies policy_groups) unless defined? OBJECT_TYPES
26
- OBJECT_NAME_SPEC = /^[\-[:alnum:]_\.]+$/ unless defined? OBJECT_NAME_SPEC
23
+ PERM_TYPES = %w{create read update delete grant}.freeze unless defined? PERM_TYPES
24
+ MEMBER_TYPES = %w{client group user}.freeze unless defined? MEMBER_TYPES
25
+ OBJECT_TYPES = %w{clients containers cookbooks data environments groups nodes roles policies policy_groups}.freeze unless defined? OBJECT_TYPES
26
+ OBJECT_NAME_SPEC = /^[\-[:alnum:]_\.]+$/.freeze unless defined? OBJECT_NAME_SPEC
27
27
 
28
28
  def validate_object_type!(type)
29
- if ! OBJECT_TYPES.include?(type)
30
- ui.fatal "Unknown object type \"#{type}\". The following types are permitted: #{OBJECT_TYPES.join(', ')}"
29
+ unless OBJECT_TYPES.include?(type)
30
+ ui.fatal "Unknown object type \"#{type}\". The following types are permitted: #{OBJECT_TYPES.join(", ")}"
31
31
  exit 1
32
32
  end
33
33
  end
34
34
 
35
35
  def validate_object_name!(name)
36
- if ! OBJECT_NAME_SPEC.match(name)
36
+ unless OBJECT_NAME_SPEC.match(name)
37
37
  ui.fatal "Invalid name: #{name}"
38
38
  exit 1
39
39
  end
40
40
  end
41
41
 
42
42
  def validate_member_type!(type)
43
- if ! MEMBER_TYPES.include?(type)
44
- ui.fatal "Unknown member type \"#{type}\". The following types are permitted: #{MEMBER_TYPES.join(', ')}"
43
+ unless MEMBER_TYPES.include?(type)
44
+ ui.fatal "Unknown member type \"#{type}\". The following types are permitted: #{MEMBER_TYPES.join(", ")}"
45
45
  exit 1
46
46
  end
47
47
  end
@@ -52,24 +52,22 @@ module OpscodeAcl
52
52
  end
53
53
 
54
54
  def validate_perm_type!(perms)
55
- perms.split(',').each do |perm|
56
- if ! PERM_TYPES.include?(perm)
57
- ui.fatal "Invalid permission \"#{perm}\". The following permissions are permitted: #{PERM_TYPES.join(',')}"
55
+ perms.split(",").each do |perm|
56
+ unless PERM_TYPES.include?(perm)
57
+ ui.fatal "Invalid permission \"#{perm}\". The following permissions are permitted: #{PERM_TYPES.join(",")}"
58
58
  exit 1
59
59
  end
60
60
  end
61
61
  end
62
62
 
63
63
  def validate_member_exists!(member_type, member_name)
64
- begin
65
- true if rest.get_rest("#{member_type}s/#{member_name}")
66
- rescue NameError
67
- # ignore "NameError: uninitialized constant Chef::ApiClient" when finding a client
68
- true
69
- rescue
70
- ui.fatal "#{member_type} '#{member_name}' does not exist"
71
- exit 1
72
- end
64
+ true if rest.get_rest("#{member_type}s/#{member_name}")
65
+ rescue NameError
66
+ # ignore "NameError: uninitialized constant Chef::ApiClient" when finding a client
67
+ true
68
+ rescue
69
+ ui.fatal "#{member_type} '#{member_name}' does not exist"
70
+ exit 1
73
71
  end
74
72
 
75
73
  def is_usag?(gname)
@@ -86,7 +84,7 @@ module OpscodeAcl
86
84
 
87
85
  def add_to_acl!(member_type, member_name, object_type, object_name, perms)
88
86
  acl = get_acl(object_type, object_name)
89
- perms.split(',').each do |perm|
87
+ perms.split(",").each do |perm|
90
88
  ui.msg "Adding '#{member_name}' to '#{perm}' ACE of '#{object_name}'"
91
89
  ace = acl[perm]
92
90
 
@@ -99,12 +97,14 @@ module OpscodeAcl
99
97
  # Older version of chef-server will continue to use 'actors' for a combined list
100
98
  # and expect the same in the body.
101
99
  key = "#{member_type}s"
102
- key = 'actors' unless ace.has_key? key
100
+ key = "actors" unless ace.key? key
103
101
  next if ace[key].include?(member_name)
102
+
104
103
  ace[key] << member_name
105
104
  when "group"
106
- next if ace['groups'].include?(member_name)
107
- ace['groups'] << member_name
105
+ next if ace["groups"].include?(member_name)
106
+
107
+ ace["groups"] << member_name
108
108
  end
109
109
 
110
110
  update_ace!(object_type, object_name, perm, ace)
@@ -113,19 +113,21 @@ module OpscodeAcl
113
113
 
114
114
  def remove_from_acl!(member_type, member_name, object_type, object_name, perms)
115
115
  acl = get_acl(object_type, object_name)
116
- perms.split(',').each do |perm|
116
+ perms.split(",").each do |perm|
117
117
  ui.msg "Removing '#{member_name}' from '#{perm}' ACE of '#{object_name}'"
118
118
  ace = acl[perm]
119
119
 
120
120
  case member_type
121
121
  when "client", "user"
122
122
  key = "#{member_type}s"
123
- key = 'actors' unless ace.has_key? key
123
+ key = "actors" unless ace.key? key
124
124
  next unless ace[key].include?(member_name)
125
+
125
126
  ace[key].delete(member_name)
126
127
  when "group"
127
- next unless ace['groups'].include?(member_name)
128
- ace['groups'].delete(member_name)
128
+ next unless ace["groups"].include?(member_name)
129
+
130
+ ace["groups"].delete(member_name)
129
131
  end
130
132
 
131
133
  update_ace!(object_type, object_name, perm, ace)
@@ -140,7 +142,7 @@ module OpscodeAcl
140
142
  validate_member_exists!(member_type, member_name)
141
143
  existing_group = rest.get_rest("groups/#{group_name}")
142
144
  ui.msg "Adding '#{member_name}' to '#{group_name}' group"
143
- if !existing_group["#{member_type}s"].include?(member_name)
145
+ unless existing_group["#{member_type}s"].include?(member_name)
144
146
  existing_group["#{member_type}s"] << member_name
145
147
  new_group = {
146
148
  "groupname" => existing_group["groupname"],
@@ -148,8 +150,8 @@ module OpscodeAcl
148
150
  "actors" => {
149
151
  "users" => existing_group["users"],
150
152
  "clients" => existing_group["clients"],
151
- "groups" => existing_group["groups"]
152
- }
153
+ "groups" => existing_group["groups"],
154
+ },
153
155
  }
154
156
  rest.put_rest("groups/#{group_name}", new_group)
155
157
  end
@@ -167,8 +169,8 @@ module OpscodeAcl
167
169
  "actors" => {
168
170
  "users" => existing_group["users"],
169
171
  "clients" => existing_group["clients"],
170
- "groups" => existing_group["groups"]
171
- }
172
+ "groups" => existing_group["groups"],
173
+ },
172
174
  }
173
175
  rest.put_rest("groups/#{group_name}", new_group)
174
176
  end
@@ -22,7 +22,7 @@ module OpscodeAcl
22
22
  banner "knife acl bulk add MEMBER_TYPE MEMBER_NAME OBJECT_TYPE REGEX PERMS"
23
23
 
24
24
  deps do
25
- require 'chef/knife/acl_base'
25
+ require_relative "acl_base"
26
26
  include OpscodeAcl::AclBase
27
27
  end
28
28
 
@@ -36,7 +36,7 @@ module OpscodeAcl
36
36
  exit 1
37
37
  end
38
38
 
39
- unless %w(client group).include?(member_type)
39
+ unless %w{client group}.include?(member_type)
40
40
  ui.fatal "ERROR: To enforce best practice, knife-acl can only add a client or a group to an ACL."
41
41
  ui.fatal " See the knife-acl README for more information."
42
42
  exit 1
@@ -46,7 +46,7 @@ module OpscodeAcl
46
46
  validate_object_type!(object_type)
47
47
  validate_member_exists!(member_type, member_name)
48
48
 
49
- if %w(containers groups).include?(object_type)
49
+ if %w{containers groups}.include?(object_type)
50
50
  ui.fatal "bulk modifying the ACL of #{object_type} is not permitted"
51
51
  exit 1
52
52
  end
@@ -22,7 +22,7 @@ module OpscodeAcl
22
22
  banner "knife acl bulk remove MEMBER_TYPE MEMBER_NAME OBJECT_TYPE REGEX PERMS"
23
23
 
24
24
  deps do
25
- require 'chef/knife/acl_base'
25
+ require_relative "acl_base"
26
26
  include OpscodeAcl::AclBase
27
27
  end
28
28
 
@@ -36,11 +36,11 @@ module OpscodeAcl
36
36
  exit 1
37
37
  end
38
38
 
39
- if member_name == 'pivotal' && %w(client user).include?(member_type)
39
+ if member_name == "pivotal" && %w{client user}.include?(member_type)
40
40
  ui.fatal "ERROR: 'pivotal' is a system user so knife-acl will not remove it from an ACL."
41
41
  exit 1
42
42
  end
43
- if member_name == 'admins' && member_type == 'group' && perms.to_s.split(',').include?('grant')
43
+ if member_name == "admins" && member_type == "group" && perms.to_s.split(",").include?("grant")
44
44
  ui.fatal "ERROR: knife-acl will not remove the 'admins' group from the 'grant' ACE."
45
45
  ui.fatal " Removal could prevent future attempts to modify permissions."
46
46
  exit 1
@@ -51,7 +51,7 @@ module OpscodeAcl
51
51
  validate_object_type!(object_type)
52
52
  validate_member_exists!(member_type, member_name)
53
53
 
54
- if %w(containers groups).include?(object_type)
54
+ if %w{containers groups}.include?(object_type)
55
55
  ui.fatal "bulk modifying the ACL of #{object_type} is not permitted"
56
56
  exit 1
57
57
  end
@@ -23,7 +23,7 @@ module OpscodeAcl
23
23
  banner "knife acl remove MEMBER_TYPE MEMBER_NAME OBJECT_TYPE OBJECT_NAME PERMS"
24
24
 
25
25
  deps do
26
- require 'chef/knife/acl_base'
26
+ require_relative "acl_base"
27
27
  include OpscodeAcl::AclBase
28
28
  end
29
29
 
@@ -36,11 +36,11 @@ module OpscodeAcl
36
36
  exit 1
37
37
  end
38
38
 
39
- if member_name == 'pivotal' && %w(client user).include?(member_type)
39
+ if member_name == "pivotal" && %w{client user}.include?(member_type)
40
40
  ui.fatal "ERROR: 'pivotal' is a system user so knife-acl will not remove it from an ACL."
41
41
  exit 1
42
42
  end
43
- if member_name == 'admins' && member_type == 'group' && perms.to_s.split(',').include?('grant')
43
+ if member_name == "admins" && member_type == "group" && perms.to_s.split(",").include?("grant")
44
44
  ui.fatal "ERROR: knife-acl will not remove the 'admins' group from the 'grant' ACE."
45
45
  ui.fatal " Removal could prevent future attempts to modify permissions."
46
46
  exit 1
@@ -22,7 +22,7 @@ module OpscodeAcl
22
22
  banner "knife acl show OBJECT_TYPE OBJECT_NAME"
23
23
 
24
24
  deps do
25
- require 'chef/knife/acl_base'
25
+ require_relative "acl_base"
26
26
  include OpscodeAcl::AclBase
27
27
  end
28
28
 
@@ -42,8 +42,8 @@ module OpscodeAcl
42
42
  # Filter out the actors field if we have
43
43
  # users and clients. Note that if one is present,
44
44
  # both will be - but we're checking both for completeness.
45
- if acl[perm].has_key?('users') && acl[perm].has_key?('clients')
46
- acl[perm].delete 'actors'
45
+ if acl[perm].key?("users") && acl[perm].key?("clients")
46
+ acl[perm].delete "actors"
47
47
  end
48
48
  end
49
49
  ui.output acl
@@ -23,7 +23,7 @@ module OpscodeAcl
23
23
  banner "knife group add MEMBER_TYPE MEMBER_NAME GROUP_NAME"
24
24
 
25
25
  deps do
26
- require 'chef/knife/acl_base'
26
+ require_relative "acl_base"
27
27
  include OpscodeAcl::AclBase
28
28
  end
29
29
 
@@ -23,7 +23,7 @@ module OpscodeAcl
23
23
  banner "knife group create GROUP_NAME"
24
24
 
25
25
  deps do
26
- require 'chef/knife/acl_base'
26
+ require_relative "acl_base"
27
27
  include OpscodeAcl::AclBase
28
28
  end
29
29
 
@@ -39,7 +39,7 @@ module OpscodeAcl
39
39
  validate_member_name!(group_name)
40
40
 
41
41
  ui.msg "Creating '#{group_name}' group"
42
- rest.post_rest("groups", {:groupname => group_name})
42
+ rest.post_rest("groups", { groupname: group_name })
43
43
  end
44
44
  end
45
45
  end
@@ -23,7 +23,7 @@ module OpscodeAcl
23
23
  banner "knife group destroy GROUP_NAME"
24
24
 
25
25
  deps do
26
- require 'chef/knife/acl_base'
26
+ require_relative "acl_base"
27
27
  include OpscodeAcl::AclBase
28
28
  end
29
29
 
@@ -38,7 +38,7 @@ module OpscodeAcl
38
38
 
39
39
  validate_member_name!(group_name)
40
40
 
41
- if %w(admins billing-admins clients users).include?(group_name.downcase)
41
+ if %w{admins billing-admins clients users}.include?(group_name.downcase)
42
42
  ui.fatal "the '#{group_name}' group is a special group that should not be destroyed"
43
43
  exit 1
44
44
  end
@@ -23,7 +23,7 @@ module OpscodeAcl
23
23
  banner "knife group list"
24
24
 
25
25
  deps do
26
- require 'chef/knife/acl_base'
26
+ require_relative "acl_base"
27
27
  include OpscodeAcl::AclBase
28
28
  end
29
29
 
@@ -23,7 +23,7 @@ module OpscodeAcl
23
23
  banner "knife group remove MEMBER_TYPE MEMBER_NAME GROUP_NAME"
24
24
 
25
25
  deps do
26
- require 'chef/knife/acl_base'
26
+ require_relative "acl_base"
27
27
  include OpscodeAcl::AclBase
28
28
  end
29
29
 
@@ -23,7 +23,7 @@ module OpscodeAcl
23
23
  banner "knife group show GROUP_NAME"
24
24
 
25
25
  deps do
26
- require 'chef/knife/acl_base'
26
+ require_relative "acl_base"
27
27
  include OpscodeAcl::AclBase
28
28
  end
29
29
 
@@ -19,7 +19,7 @@
19
19
  module OpscodeAcl
20
20
  class UserDissociate < Chef::Knife
21
21
  category "OPSCODE HOSTED CHEF ACCESS CONTROL"
22
- banner 'knife user dissociate USERNAMES'
22
+ banner "knife user dissociate USERNAMES"
23
23
 
24
24
  def run
25
25
  if name_args.length < 1
@@ -28,7 +28,7 @@ module OpscodeAcl
28
28
  exit 1
29
29
  end
30
30
  users = name_args
31
- ui.confirm("Are you sure you want to dissociate the following users: #{users.join(', ')}")
31
+ ui.confirm("Are you sure you want to dissociate the following users: #{users.join(", ")}")
32
32
  users.each do |u|
33
33
  api_endpoint = "users/#{u}"
34
34
  rest.delete_rest(api_endpoint)
@@ -19,10 +19,9 @@
19
19
  module OpscodeAcl
20
20
  class UserInviteAdd < Chef::Knife
21
21
  category "OPSCODE HOSTED CHEF ACCESS CONTROL"
22
- banner 'knife user invite add USERNAMES'
22
+ banner "knife user invite add USERNAMES"
23
23
 
24
24
  def run
25
-
26
25
  if name_args.length < 1
27
26
  show_usage
28
27
  ui.fatal("You must specify a username.")
@@ -32,7 +31,7 @@ module OpscodeAcl
32
31
  users = name_args
33
32
  api_endpoint = "association_requests/"
34
33
  users.each do |u|
35
- body = {:user => u}
34
+ body = { user: u }
36
35
  rest.post_rest(api_endpoint, body)
37
36
  end
38
37
  end
@@ -19,11 +19,11 @@
19
19
  module OpscodeAcl
20
20
  class UserInviteList < Chef::Knife
21
21
  category "OPSCODE HOSTED CHEF ACCESS CONTROL"
22
- banner 'knife user invite list'
22
+ banner "knife user invite list"
23
23
 
24
24
  def run
25
25
  api_endpoint = "association_requests/"
26
- invited_users = rest.get_rest(api_endpoint).map { |i| i['username'] }
26
+ invited_users = rest.get_rest(api_endpoint).map { |i| i["username"] }
27
27
  ui.output(invited_users)
28
28
  end
29
29
  end
@@ -18,16 +18,16 @@
18
18
 
19
19
  module OpscodeAcl
20
20
  class UserInviteRecind < Chef::Knife
21
- banner 'knife user invite recind [USERNAMES] (options)'
21
+ banner "knife user invite recind [USERNAMES] (options)"
22
22
  category "OPSCODE HOSTED CHEF ACCESS CONTROL"
23
23
 
24
24
  option :all,
25
- :short => "-a",
26
- :long => "--all",
27
- :description => "Recind all invites!"
25
+ short: "-a",
26
+ long: "--all",
27
+ description: "Recind all invites!"
28
28
 
29
29
  def run
30
- if name_args.length < 1 and ! config.has_key?(:all)
30
+ if (name_args.length < 1) && ! config.key?(:all)
31
31
  show_usage
32
32
  ui.fatal("You must specify a username.")
33
33
  exit 1
@@ -35,18 +35,18 @@ module OpscodeAcl
35
35
 
36
36
  # To recind we need to send a DELETE to association_requests/INVITE_ID
37
37
  # For user friendliness we look up the invite ID based on username.
38
- @invites = Hash.new
38
+ @invites = {}
39
39
  usernames = name_args
40
- rest.get_rest("association_requests").each { |i| @invites[i['username']] = i['id'] }
40
+ rest.get_rest("association_requests").each { |i| @invites[i["username"]] = i["id"] }
41
41
  if config[:all]
42
42
  ui.confirm("Are you sure you want to recind all association requests")
43
- @invites.each do |u,i|
43
+ @invites.each do |u, i|
44
44
  rest.delete_rest("association_requests/#{i}")
45
45
  end
46
46
  else
47
- ui.confirm("Are you sure you want to recind the association requests for: #{usernames.join(', ')}")
47
+ ui.confirm("Are you sure you want to recind the association requests for: #{usernames.join(", ")}")
48
48
  usernames.each do |u|
49
- if @invites.has_key?(u)
49
+ if @invites.key?(u)
50
50
  rest.delete_rest("association_requests/#{@invites[u]}")
51
51
  else
52
52
  ui.fatal("No association request for #{u}.")
@@ -23,7 +23,7 @@ module OpscodeAcl
23
23
  banner "knife user list"
24
24
 
25
25
  deps do
26
- require 'pp'
26
+ require "pp"
27
27
  end
28
28
 
29
29
  def run
@@ -32,4 +32,3 @@ module OpscodeAcl
32
32
  end
33
33
  end
34
34
  end
35
-
@@ -19,16 +19,16 @@
19
19
  module OpscodeAcl
20
20
  class UserShow < Chef::Knife
21
21
  category "OPSCODE HOSTED CHEF ACCESS CONTROL"
22
- banner 'knife user show [USERNAME]'
22
+ banner "knife user show [USERNAME]"
23
23
 
24
24
  # ui.format_for_display has logic to handle displaying
25
25
  # any attributes set in the config[:attribute] Array.
26
26
  attrs_to_show = []
27
27
  option :attribute,
28
- :short => "-a [ATTR]",
29
- :long => "--attribute [ATTR]",
30
- :proc => lambda {|val| attrs_to_show << val},
31
- :description => "Show attribute ATTR. Use multiple times to show multiple attributes."
28
+ short: "-a [ATTR]",
29
+ long: "--attribute [ATTR]",
30
+ proc: lambda { |val| attrs_to_show << val },
31
+ description: "Show attribute ATTR. Use multiple times to show multiple attributes."
32
32
 
33
33
  def run
34
34
  if name_args.length < 1
@@ -1,3 +1,3 @@
1
1
  module KnifeACL
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.6".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-acl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Falcon
@@ -9,18 +9,16 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-09-01 00:00:00.000000000 Z
12
+ date: 2019-12-30 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Knife plugin to manupulate Chef server access control lists
15
15
  email: support@chef.io
16
16
  executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files:
19
- - README.md
20
19
  - LICENSE
21
20
  files:
22
21
  - LICENSE
23
- - README.md
24
22
  - lib/chef/knife/acl_add.rb
25
23
  - lib/chef/knife/acl_base.rb
26
24
  - lib/chef/knife/acl_bulk_add.rb
@@ -58,8 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
56
  - !ruby/object:Gem::Version
59
57
  version: '0'
60
58
  requirements: []
61
- rubyforge_project:
62
- rubygems_version: 2.6.6
59
+ rubygems_version: 3.0.3
63
60
  signing_key:
64
61
  specification_version: 4
65
62
  summary: Knife plugin to manupulate Chef server access control lists
data/README.md DELETED
@@ -1,463 +0,0 @@
1
- # knife-acl
2
-
3
- ## Description
4
-
5
- This is a Chef Software, Inc.-supported knife plugin which provides some user/group
6
- ACL operations for Chef server.
7
-
8
- All commands assume a working knife configuration for an admin user of a Chef organization.
9
-
10
- Reference:
11
-
12
- 1. [Chef Server Permissions PDF](https://github.com/chef/chef-server/blob/master/doc/ChefServerPermissions_v1.3.pdf)
13
- 2. [Chef Server Permissions Docs](https://docs.chef.io/server/server_orgs.html#permissions)
14
- 3. [Chef Server Groups Docs](https://docs.chef.io/server/server_orgs.html#groups)
15
-
16
- ### Installation
17
-
18
- Install into [Chef DK](https://downloads.chef.io/chef-dk/).
19
-
20
- chef gem install knife-acl
21
-
22
- ### _Warning about Users group_
23
-
24
- The "Users" group is a special group and should not be managed with knife-acl.
25
- As such, knife-acl will give an error if either `knife acl group add user users USER`
26
- or `knife acl group remove user users USER` are run.
27
-
28
- ### Chef Server Roles Based Access Control (RBAC) Summary
29
-
30
- In the context of the Chef Server's API a container is just the API endpoint used
31
- when creating a new object of a particular object type.
32
-
33
- For example, the container for creating client objects is called `clients` and
34
- the container for creating node objects is called `nodes`.
35
-
36
- Two containers are used when creating (uploading) cookbooks.
37
- The `cookbooks` and `sandboxes` containers.
38
-
39
- Here is a full list of the containers in a Chef Server.
40
-
41
- - clients
42
- - cookbooks
43
- - data
44
- - environments
45
- - groups
46
- - nodes
47
- - policies
48
- - policy_groups
49
- - roles
50
- - sandboxes
51
-
52
- The permissions assigned to a container are inherited by the objects
53
- that the container creates. When a permission is changed on a container
54
- that change will only affect new objects. The change does not propagate to
55
- existing objects.
56
-
57
- For reference and restoral purposes the
58
- [Default Permissions for Containers](#default-permissions-for-containers) section
59
- of this document contains `knife-acl` commands that will set the default
60
- permissions for the admins, clients and users groups on all containers.
61
- These can be helpful if you need to restore container permissions back to their
62
- default values.
63
-
64
- #### Permissions Management Best Practice
65
-
66
- The best practice for managing permissions is to only add clients and groups to an objects' permissions.
67
-
68
- Adding a user to an objects' permissions is possible by first adding the group to the permissions and
69
- then adding the user to the group. This is much easier to maintain when compared to adding
70
- individual users to each objects' permissions.
71
-
72
- To enforce this the `knife acl add` and `knife acl bulk add` commands can only add a client or a group
73
- to an objects' permissions.
74
-
75
- If a group ever needs to be removed from the permissions of all objects the group can simply
76
- be deleted.
77
-
78
- #### Setup Default Read-Only Access for Non-admin Users
79
-
80
- The "Users" group by default provides regular (non-admin) users a lot of access to modify objects in
81
- the Chef Server.
82
-
83
- Removing the "Users" group from the "create", "update", "delete" and "grant" Access Control Entries (ACEs)
84
- of all objects and containers will create a default read-only access for non-admin users.
85
-
86
- To completely prevent non-admin users from accessing all objects and containers then also remove the
87
- "Users" group from the "read" ACE.
88
-
89
- Admin users will still have default admin access to all objects and containers.
90
-
91
- **NOTE:** Please note that currently the Chef Manage web UI will appear to allow read-only users to edit
92
- some objects. However, the changes are not actually saved and they disappear when the read-only
93
- user refreshes the page.
94
-
95
- ```
96
- knife acl remove group users containers clients create,update,delete,grant
97
- knife acl bulk remove group users clients '.*' create,update,delete,grant
98
-
99
-
100
- knife acl remove group users containers sandboxes create,update,delete,grant
101
- knife acl remove group users containers cookbooks create,update,delete,grant
102
- knife acl bulk remove group users cookbooks '.*' create,update,delete,grant
103
-
104
-
105
- knife acl remove group users containers data create,update,delete,grant
106
- knife acl bulk remove group users data '.*' create,update,delete,grant
107
-
108
-
109
- knife acl remove group users containers environments create,update,delete,grant
110
- knife acl bulk remove group users environments '.*' create,update,delete,grant
111
-
112
-
113
- knife acl remove group users containers nodes create,update,delete,grant
114
- knife acl bulk remove group users nodes '.*' create,update,delete,grant
115
-
116
-
117
- knife acl remove group users containers policies create,update,delete,grant
118
- knife acl bulk remove group users policies '.*' create,update,delete,grant
119
-
120
-
121
- knife acl remove group users containers policy_groups create,update,delete,grant
122
- knife acl bulk remove group users policy_groups '.*' create,update,delete,grant
123
-
124
-
125
- knife acl remove group users containers roles create,update,delete,grant
126
- knife acl bulk remove group users roles '.*' create,update,delete,grant
127
- ```
128
-
129
- #### Selectively Allow Access
130
-
131
- You can also create a new group and manage its members with knife-acl or the Manage web interface.
132
-
133
- Then add this group to the ACEs of all appropriate containers and/or objects according to your requirements.
134
-
135
- #### Create read-only group with read only access
136
-
137
- The following set of commands creates a group named `read-only` and
138
- gives it `read` access on all objects.
139
-
140
- ```
141
- knife group create read-only
142
-
143
-
144
- knife acl add group read-only containers clients read
145
- knife acl bulk add group read-only clients '.*' read
146
-
147
-
148
- knife acl add group read-only containers sandboxes read
149
- knife acl add group read-only containers cookbooks read
150
- knife acl bulk add group read-only cookbooks '.*' read
151
-
152
-
153
- knife acl add group read-only containers data read
154
- knife acl bulk add group read-only data '.*' read
155
-
156
-
157
- knife acl add group read-only containers environments read
158
- knife acl bulk add group read-only environments '.*' read
159
-
160
-
161
- knife acl add group read-only containers nodes read
162
- knife acl bulk add group read-only nodes '.*' read
163
-
164
-
165
- knife acl add group read-only containers policies read
166
- knife acl bulk add group read-only policies '.*' read
167
-
168
-
169
- knife acl add group read-only containers policy_groups read
170
- knife acl bulk add group read-only policy_groups '.*' read
171
-
172
-
173
- knife acl add group read-only containers roles read
174
- knife acl bulk add group read-only roles '.*' read
175
- ```
176
-
177
- # Subcommands
178
-
179
- ## knife user list
180
-
181
- Show a list of users associated with your organization
182
-
183
- ## knife group list
184
-
185
- List groups in the organization.
186
-
187
- ## knife group create GROUP_NAME
188
-
189
- Create a new group `GROUP_NAME` to the organization.
190
-
191
- ## knife group show GROUP_NAME
192
-
193
- Show the membership details for `GROUP_NAME`.
194
-
195
- ## knife group add MEMBER_TYPE MEMBER_NAME GROUP_NAME
196
-
197
- Add MEMBER_NAME to `GROUP_NAME`.
198
-
199
- Valid `MEMBER_TYPE` values are
200
-
201
- - client
202
- - group
203
- - user
204
-
205
- ## knife group remove MEMBER_TYPE MEMBER_NAME GROUP_NAME
206
-
207
- Remove `MEMBER_NAME` from `GROUP_NAME`.
208
-
209
- See the `knife group add` documentation above for valid `MEMBER_TYPE` values.
210
-
211
- ## knife group destroy GROUP_NAME
212
-
213
- Removes group `GROUP_NAME` from the organization. All members of the group
214
- (clients, groups and users) remain in the system, only `GROUP_NAME` is removed.
215
-
216
- The `admins`, `billing-admins`, `clients` and `users` groups are special groups
217
- so knife-acl will not allow them to be destroyed.
218
-
219
- ## knife acl show OBJECT_TYPE OBJECT_NAME
220
-
221
- Shows the ACL for the specified object. Objects are identified by the
222
- combination of their type and name.
223
-
224
- Valid `OBJECT_TYPE` values are
225
-
226
- - clients
227
- - containers
228
- - cookbooks
229
- - data
230
- - environments
231
- - groups
232
- - nodes
233
- - policies
234
- - policy_groups
235
- - roles
236
-
237
- For example, use the following command to obtain the ACL for a node
238
- named "web.example.com":
239
-
240
- knife acl show nodes web.example.com
241
-
242
- ## knife acl add MEMBER_TYPE MEMBER_NAME OBJECT_TYPE OBJECT_NAME PERMS
243
-
244
- The best practice is to only add clients and groups to ACLs. To enforce this best practice
245
- the `knife acl add` command is only able to add a client or a group to ACLs.
246
-
247
- Valid `MEMBER_TYPE` values are
248
-
249
- - client
250
- - group
251
-
252
- Add `MEMBER_NAME` to the `PERMS` access control entry of `OBJECT_NAME`.
253
- Objects are specified by the combination of their type and name.
254
-
255
- Valid `OBJECT_TYPE` values are
256
-
257
- - clients
258
- - containers
259
- - cookbooks
260
- - data
261
- - environments
262
- - groups
263
- - nodes
264
- - policies
265
- - policy_groups
266
- - roles
267
-
268
- Valid `PERMS` are:
269
-
270
- - create
271
- - read
272
- - update
273
- - delete
274
- - grant
275
-
276
- Multiple `PERMS` can be given in a single command by separating them
277
- with a comma with no extra spaces.
278
-
279
- For example, use the following command to give the superusers group
280
- the ability to delete and update the node called "web.example.com":
281
-
282
- knife acl add group superusers nodes web.example.com delete,update
283
-
284
- ## knife acl bulk add MEMBER_TYPE MEMBER_NAME OBJECT_TYPE REGEX PERMS
285
-
286
- The best practice is to only add clients and groups to ACLs. To enforce this best practice
287
- the `knife acl bulk add` command is only able to add a client or a group to ACLs.
288
-
289
- Valid `MEMBER_TYPE` values are
290
-
291
- - client
292
- - group
293
-
294
- Add `MEMBER_NAME` to the `PERMS` access control entry for each object in a
295
- set of objects of `OBJECT_TYPE`.
296
-
297
- The set of objects are specified by matching the objects' names with the
298
- given REGEX regular expression surrounded by quotes.
299
-
300
- See the `knife acl add` documentation above for valid `OBJECT_TYPE` and `PERMS` values.
301
-
302
- Appending `-y` or `--yes` to the `knife acl bulk add` command will run the command
303
- without any prompts for confirmation.
304
-
305
- For example, use the following command to give the superusers group the ability to
306
- delete and update all nodes matching the regular expression 'WIN-.*':
307
-
308
- knife acl bulk add group superusers nodes 'WIN-.*' delete,update --yes
309
-
310
- ## knife acl remove MEMBER_TYPE MEMBER_NAME OBJECT_TYPE OBJECT_NAME PERMS
311
-
312
- Remove `MEMBER_NAME` from the `PERMS` access control entry of `OBJECT_NAME`.
313
- Objects are specified by the combination of their type and name.
314
-
315
- Valid `MEMBER_TYPE` values are
316
-
317
- - client
318
- - group
319
- - user
320
-
321
- Valid `OBJECT_TYPE` values are
322
-
323
- - clients
324
- - containers
325
- - cookbooks
326
- - data
327
- - environments
328
- - groups
329
- - nodes
330
- - policies
331
- - policy_groups
332
- - roles
333
-
334
- Valid `PERMS` are:
335
-
336
- - create
337
- - read
338
- - update
339
- - delete
340
- - grant
341
-
342
- Multiple `PERMS` can be given in a single command by separating them
343
- with a comma with no extra spaces.
344
-
345
- For example, use the following command to remove the superusers group from the delete and
346
- update access control entries for the node called "web.example.com":
347
-
348
- knife acl remove group superusers nodes web.example.com delete,update
349
-
350
- ## knife acl bulk remove MEMBER_TYPE MEMBER_NAME OBJECT_TYPE REGEX PERMS
351
-
352
- Remove `MEMBER_NAME` from the `PERMS` access control entry for each object in a
353
- set of objects of `OBJECT_TYPE`.
354
-
355
- The set of objects are specified by matching the objects' names with the
356
- given REGEX regular expression surrounded by quotes.
357
-
358
- See the `knife acl remove` documentation above for valid `MEMBER_TYPE`, `OBJECT_TYPE` and `PERMS` values.
359
-
360
- Appending `-y` or `--yes` to the `knife acl bulk add` command will run the command
361
- without any prompts for confirmation.
362
-
363
- For example, use the following command to remove the superusers group from the delete and
364
- update access control entries for all nodes matching the regular expression 'WIN-.*':
365
-
366
- knife acl bulk remove group superusers nodes 'WIN-.*' delete,update --yes
367
-
368
- ## Default Permissions for Containers
369
-
370
- The following commands will set the default permissions for the
371
- admins, clients and users groups on all containers. These can
372
- be helpful if you need to restore container permissions back to their
373
- default values.
374
-
375
- ```
376
- knife acl add group admins containers clients create,read,update,delete,grant
377
- knife acl remove group clients containers clients create,read,update,delete,grant
378
- knife acl add group users containers clients read,delete
379
- knife acl remove group users containers clients create,update,grant
380
-
381
- knife acl add group admins containers cookbook_artifacts create,read,update,delete,grant
382
- knife acl add group clients containers cookbook_artifacts read
383
- knife acl remove group clients containers cookbook_artifacts create,update,delete,grant
384
- knife acl add group users containers cookbook_artifacts create,read,update,delete
385
- knife acl remove group users containers cookbook_artifacts grant
386
-
387
- knife acl add group admins containers cookbooks create,read,update,delete,grant
388
- knife acl add group clients containers cookbooks read
389
- knife acl remove group clients containers cookbooks create,update,delete,grant
390
- knife acl add group users containers cookbooks create,read,update,delete
391
- knife acl remove group users containers cookbooks grant
392
-
393
- knife acl add group admins containers data create,read,update,delete,grant
394
- knife acl add group clients containers data read
395
- knife acl remove group clients containers data create,update,delete,grant
396
- knife acl add group users containers data create,read,update,delete
397
- knife acl remove group users containers data grant
398
-
399
- knife acl add group admins containers environments create,read,update,delete,grant
400
- knife acl add group clients containers environments read
401
- knife acl remove group clients containers environments create,update,delete,grant
402
- knife acl add group users containers environments create,read,update,delete
403
- knife acl remove group users containers environments grant
404
-
405
- knife acl add group admins containers groups create,read,update,delete,grant
406
- knife acl remove group clients containers groups create,read,update,delete,grant
407
- knife acl add group users containers groups read
408
- knife acl remove group users containers groups create,update,delete,grant
409
-
410
- knife acl add group admins containers nodes create,read,update,delete,grant
411
- knife acl add group clients containers nodes create,read
412
- knife acl remove group clients containers nodes update,delete,grant
413
- knife acl add group users containers nodes create,read,update,delete
414
- knife acl remove group users containers nodes grant
415
-
416
- knife acl add group admins containers policies create,read,update,delete,grant
417
- knife acl add group clients containers policies read
418
- knife acl remove group clients containers policies create,update,delete,grant
419
- knife acl add group users containers policies create,read,update,delete
420
- knife acl remove group users containers policies grant
421
-
422
- knife acl add group admins containers policy_groups create,read,update,delete,grant
423
- knife acl add group clients containers policy_groups read
424
- knife acl remove group clients containers policy_groups create,update,delete,grant
425
- knife acl add group users containers policy_groups create,read,update,delete
426
- knife acl remove group users containers policy_groups grant
427
-
428
- knife acl add group admins containers roles create,read,update,delete,grant
429
- knife acl add group clients containers roles read
430
- knife acl remove group clients containers roles create,update,delete,grant
431
- knife acl add group users containers roles create,read,update,delete
432
- knife acl remove group users containers roles grant
433
-
434
- knife acl add group admins containers sandboxes create,read,update,delete,grant
435
- knife acl remove group clients containers sandboxes create,read,update,delete,grant
436
- knife acl add group users containers sandboxes create
437
- knife acl remove group users containers sandboxes read,update,delete,grant
438
- ```
439
-
440
- ## LICENSE
441
-
442
- Unless otherwise specified all works in this repository are
443
-
444
- Copyright 2013-2016 Chef Software, Inc.
445
-
446
- |||
447
- | ------------- |-------------:|
448
- | Author |Seth Falcon (seth@chef.io)|
449
- | Author |Jeremiah Snapp (jeremiah@chef.io)|
450
- | Copyright |Copyright (c) 2013-2015 Chef Software, Inc.|
451
- | License |Apache License, Version 2.0|
452
-
453
- Licensed under the Apache License, Version 2.0 (the "License");
454
- you may not use this file except in compliance with the License.
455
- You may obtain a copy of the License at
456
-
457
- [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0)
458
-
459
- Unless required by applicable law or agreed to in writing, software
460
- distributed under the License is distributed on an "AS IS" BASIS,
461
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
462
- See the License for the specific language governing permissions and
463
- limitations under the License.