knife-acl 0.0.12 → 1.0.0.beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +318 -115
- data/lib/chef/knife/acl_add.rb +16 -27
- data/lib/chef/knife/acl_base.rb +104 -21
- data/lib/chef/knife/acl_bulk_add.rb +73 -0
- data/lib/chef/knife/acl_bulk_remove.rb +78 -0
- data/lib/chef/knife/acl_remove.rb +22 -28
- data/lib/chef/knife/acl_show.rb +1 -1
- data/lib/chef/knife/group_add.rb +51 -0
- data/lib/chef/knife/group_create.rb +14 -9
- data/lib/chef/knife/group_destroy.rb +17 -7
- data/lib/chef/knife/group_list.rb +8 -10
- data/lib/chef/knife/group_remove.rb +51 -0
- data/lib/chef/knife/group_show.rb +13 -25
- data/lib/chef/knife/user_list.rb +3 -3
- data/lib/knife-acl/version.rb +1 -1
- metadata +17 -17
- data/lib/chef/knife/actor_map.rb +0 -57
- data/lib/chef/knife/group_add_actor.rb +0 -89
- data/lib/chef/knife/group_remove_actor.rb +0 -86
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d94170663f35d268be7edd8344efc0b1f52bd5f2
|
4
|
+
data.tar.gz: ad46530c182bb39277b79c18c1365cb2a2b89e3d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e78525e9f800876951c11b1aaf1bd1a4cab4ddbe144a96330cb7bdcd900be6b86beb2eef872d1f7f994e8c24193768582cf3e35fa175f4723204d5c04c9c01ce
|
7
|
+
data.tar.gz: 422f96f8129d6adc045226f3ed25f1157c3f946867f1b41ab687857c04f641b79642625afcd3262c7432c698fd171cfc77abe554f3940efc125960904d340225
|
data/README.md
CHANGED
@@ -1,163 +1,258 @@
|
|
1
|
-
# knife
|
1
|
+
# knife-acl
|
2
2
|
|
3
|
-
|
3
|
+
## Description
|
4
4
|
|
5
|
-
This is
|
6
|
-
ACL operations for
|
7
|
-
knife configuration for an organization on Enterprise Chef.
|
5
|
+
This is a Chef Software, Inc.-supported knife plugin which provides some user/group
|
6
|
+
ACL operations for Chef server.
|
8
7
|
|
9
|
-
|
8
|
+
All commands assume a working knife configuration for an admin user of a Chef organization.
|
10
9
|
|
11
|
-
|
12
|
-
organization objects to users such that it is possible to quickly revoke the
|
13
|
-
access without touching all objects in the organization.
|
10
|
+
Reference:
|
14
11
|
|
15
|
-
|
16
|
-
|
12
|
+
1. [Chef Server Permissions](http://docs.chef.io/server/server_orgs.html#permissions)
|
13
|
+
2. [Chef Server Groups](http://docs.chef.io/server/server_orgs.html#groups)
|
17
14
|
|
18
|
-
|
19
|
-
be deleted thereby quickly revoking access to all objects in the organization.
|
15
|
+
## Installation
|
20
16
|
|
21
|
-
|
22
|
-
|
17
|
+
This knife plugin is packaged as a gem. To install it, enter the
|
18
|
+
following:
|
23
19
|
|
24
|
-
|
20
|
+
The 1.0.0.beta version of knife-acl is currently recommended so be sure
|
21
|
+
to tell the gem command to install the prerelease.
|
25
22
|
|
26
|
-
|
27
|
-
|
23
|
+
#### ChefDK installed on a workstation
|
24
|
+
chef gem install knife-acl --pre
|
28
25
|
|
29
|
-
|
30
|
-
|
31
|
-
console's web interface](https://manage.opscode.com)**.
|
26
|
+
#### Omnibus installed chef on a workstation
|
27
|
+
/opt/chef/embedded/bin/gem install knife-acl --pre
|
32
28
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
29
|
+
#### Gem installed chef on a workstation
|
30
|
+
gem install knife-acl --pre
|
31
|
+
|
32
|
+
#### Opscode Enterprise Chef (OPC) Directly on the active backend
|
33
|
+
as root:
|
37
34
|
|
38
|
-
|
39
|
-
organization the user's USAG is automatically made a member of the
|
40
|
-
"Users" group. You can remove USAGs from the "Users" group using `knife-acl`
|
41
|
-
but if you click "Save Group" in the web interface then all USAGs in the
|
42
|
-
organization will be added back to the "Users" group erasing any `knife-acl`
|
43
|
-
work that was done on the "Users" group. This will happen even if no changes
|
44
|
-
were made to the group's members in the web interface.
|
35
|
+
/opt/opscode/embedded/bin/gem install knife-acl --pre
|
45
36
|
|
46
|
-
|
37
|
+
### _Warning about Users group_
|
47
38
|
|
48
|
-
|
39
|
+
The "Users" group is a special group and should not be managed with knife-acl.
|
40
|
+
As such, knife-acl will give an error if either `knife acl group add user users USER`
|
41
|
+
or `knife acl group remove user users USER` are run.
|
49
42
|
|
50
|
-
|
51
|
-
`actor-map.yaml`:
|
43
|
+
### Chef Server Roles Based Access Control (RBAC) Summary
|
52
44
|
|
53
|
-
|
45
|
+
In the context of the Chef Server's API a container is just the API endpoint used
|
46
|
+
when creating a new object of a particular object type.
|
54
47
|
|
55
|
-
|
48
|
+
For example, the container for creating client objects is called `clients` and
|
49
|
+
the container for creating node objects is called `nodes`.
|
56
50
|
|
57
|
-
|
51
|
+
Two containers are used when creating (uploading) cookbooks.
|
52
|
+
The `cookbooks` and `sandboxes` containers.
|
58
53
|
|
59
|
-
|
60
|
-
permissions given to the "read-only" group do the following:
|
54
|
+
Here is a full list of the containers in a Chef Server.
|
61
55
|
|
62
|
-
|
63
|
-
|
56
|
+
- clients
|
57
|
+
- cookbooks
|
58
|
+
- data
|
59
|
+
- environments
|
60
|
+
- groups
|
61
|
+
- nodes
|
62
|
+
- roles
|
63
|
+
- sandboxes
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
The permissions assigned to a container are inherited by the objects
|
66
|
+
that the container creates. When a permission is changed on a container
|
67
|
+
that change will only affect new objects. The change does not propagate to
|
68
|
+
existing objects.
|
68
69
|
|
69
|
-
|
70
|
+
For reference and restoral purposes the
|
71
|
+
[Default Permissions for Containers](#default-permissions-for-containers) section
|
72
|
+
of this document contains `knife-acl` commands that will set the default
|
73
|
+
permissions for the admins, clients and users groups on all containers.
|
74
|
+
These can be helpful if you need to restore container permissions back to their
|
75
|
+
default values.
|
70
76
|
|
71
|
-
|
72
|
-
following:
|
77
|
+
#### Permissions Management Best Practice
|
73
78
|
|
74
|
-
|
75
|
-
|
79
|
+
The best practice for managing permissions is to only add a group to an objects' permissions.
|
80
|
+
Then you can simply add (or remove) users or clients to the group to give the user or client
|
81
|
+
a particular set of permissions. This is much easier to maintain when compared to adding
|
82
|
+
individual users or clients to each objects' permissions.
|
76
83
|
|
77
|
-
|
78
|
-
|
84
|
+
To enforce this the `knife acl add` and `knife acl bulk add` commands can only add a group
|
85
|
+
to an objects' permissions.
|
86
|
+
|
87
|
+
If a group ever needs to be removed from the permissions of all objects the group can simply
|
88
|
+
be deleted.
|
89
|
+
|
90
|
+
#### Setup Default Read-Only Access for Non-admin Users
|
91
|
+
|
92
|
+
The "Users" group by default provides regular (non-admin) users a lot of access to modify objects in
|
93
|
+
the Chef Server.
|
94
|
+
|
95
|
+
Removing the "Users" group from the "create", "update", "delete" and "grant" Access Control Entries (ACEs)
|
96
|
+
of all objects and containers will create a default read-only access for non-admin users.
|
97
|
+
|
98
|
+
To completely prevent non-admin users from accessing all objects and containers then also remove the
|
99
|
+
"Users" group from the "read" ACE.
|
100
|
+
|
101
|
+
Admin users will still have default admin access to all objects and containers.
|
102
|
+
|
103
|
+
**NOTE:** Please note that currently the Chef Manage web UI will appear to allow read-only users to edit
|
104
|
+
some objects. However, the changes are not actually saved and they disappear when the read-only
|
105
|
+
user refreshes the page.
|
106
|
+
|
107
|
+
```
|
108
|
+
knife acl remove group users containers clients create,update,delete,grant
|
109
|
+
knife acl bulk remove group users clients '.*' create,update,delete,grant
|
110
|
+
|
111
|
+
|
112
|
+
knife acl remove group users containers sandboxes create,update,delete,grant
|
113
|
+
knife acl remove group users containers cookbooks create,update,delete,grant
|
114
|
+
knife acl bulk remove group users cookbooks '.*' create,update,delete,grant
|
115
|
+
|
116
|
+
|
117
|
+
knife acl remove group users containers data create,update,delete,grant
|
118
|
+
knife acl bulk remove group users data '.*' create,update,delete,grant
|
119
|
+
|
120
|
+
|
121
|
+
knife acl remove group users containers environments create,update,delete,grant
|
122
|
+
knife acl bulk remove group users environments '.*' create,update,delete,grant
|
79
123
|
|
80
|
-
|
81
|
-
|
124
|
+
|
125
|
+
knife acl remove group users containers nodes create,update,delete,grant
|
126
|
+
knife acl bulk remove group users nodes '.*' create,update,delete,grant
|
127
|
+
|
128
|
+
|
129
|
+
knife acl remove group users containers roles create,update,delete,grant
|
130
|
+
knife acl bulk remove group users roles '.*' create,update,delete,grant
|
131
|
+
```
|
132
|
+
|
133
|
+
#### Selectively Allow Access
|
134
|
+
|
135
|
+
You can also create a new group and manage its members with knife-acl or the Manage web interface.
|
136
|
+
|
137
|
+
Then add this group to the ACEs of all appropriate containers and/or objects according to your requirements.
|
138
|
+
|
139
|
+
#### Create read-only group with read only access
|
140
|
+
|
141
|
+
The following set of commands creates a group named `read-only` and
|
142
|
+
gives it `read` access on all objects.
|
143
|
+
|
144
|
+
```
|
145
|
+
knife group create read-only
|
146
|
+
|
147
|
+
|
148
|
+
knife acl add group read-only containers clients read
|
149
|
+
knife acl bulk add group read-only clients '.*' read
|
150
|
+
|
151
|
+
|
152
|
+
knife acl add group read-only containers sandboxes read
|
153
|
+
knife acl add group read-only containers cookbooks read
|
154
|
+
knife acl bulk add group read-only cookbooks '.*' read
|
155
|
+
|
156
|
+
|
157
|
+
knife acl add group read-only containers data read
|
158
|
+
knife acl bulk add group read-only data '.*' read
|
159
|
+
|
160
|
+
|
161
|
+
knife acl add group read-only containers environments read
|
162
|
+
knife acl bulk add group read-only environments '.*' read
|
163
|
+
|
164
|
+
|
165
|
+
knife acl add group read-only containers nodes read
|
166
|
+
knife acl bulk add group read-only nodes '.*' read
|
167
|
+
|
168
|
+
|
169
|
+
knife acl add group read-only containers roles read
|
170
|
+
knife acl bulk add group read-only roles '.*' read
|
171
|
+
```
|
82
172
|
|
83
173
|
# Subcommands
|
84
174
|
|
85
175
|
## knife user list
|
86
176
|
|
87
|
-
Show a list of users associated with your
|
177
|
+
Show a list of users associated with your organization
|
88
178
|
|
89
|
-
## knife
|
179
|
+
## knife group list
|
90
180
|
|
91
|
-
|
92
|
-
and stores a list of clients.
|
181
|
+
List groups in the organization.
|
93
182
|
|
94
|
-
|
95
|
-
as a local cache of clients and is used by the following commands:
|
96
|
-
- `knife group show`,
|
97
|
-
- `knife group add actor`, and
|
98
|
-
- `knife group remove actor`.
|
183
|
+
## knife group create GROUP_NAME
|
99
184
|
|
100
|
-
|
185
|
+
Create a new group `GROUP_NAME` to the organization.
|
101
186
|
|
102
|
-
|
187
|
+
## knife group show GROUP_NAME
|
103
188
|
|
104
|
-
|
189
|
+
Show the membership details for `GROUP_NAME`.
|
105
190
|
|
106
|
-
|
191
|
+
## knife group add MEMBER_TYPE MEMBER_NAME GROUP_NAME
|
107
192
|
|
108
|
-
|
193
|
+
Add MEMBER_NAME to `GROUP_NAME`.
|
109
194
|
|
110
|
-
|
111
|
-
`knife actor map`, the user map file will be used to annotate USAGs so
|
112
|
-
you can see what user they represent.
|
195
|
+
Valid `MEMBER_TYPE` values are
|
113
196
|
|
114
|
-
|
197
|
+
- client
|
198
|
+
- group
|
199
|
+
- user
|
115
200
|
|
116
|
-
|
117
|
-
name. Requires an up-to-date actor map as created by `knife actor
|
118
|
-
map`. The user's USAG will be added as a subgroup of GROUP if ACTOR
|
119
|
-
is a user.
|
201
|
+
## knife group remove MEMBER_TYPE MEMBER_NAME GROUP_NAME
|
120
202
|
|
121
|
-
|
203
|
+
Remove `MEMBER_NAME` from `GROUP_NAME`.
|
122
204
|
|
123
|
-
|
124
|
-
`knife actor map`. The user's USAG will be removed from the subgroups
|
125
|
-
of GROUP if ACTOR is a user.
|
205
|
+
See the `knife group add` documentation above for valid `MEMBER_TYPE` values.
|
126
206
|
|
127
|
-
## knife group destroy
|
207
|
+
## knife group destroy GROUP_NAME
|
128
208
|
|
129
|
-
Removes `
|
130
|
-
|
209
|
+
Removes group `GROUP_NAME` from the organization. All members of the group
|
210
|
+
(clients, groups and users) remain in the system, only `GROUP_NAME` is removed.
|
211
|
+
|
212
|
+
The `admins`, `billing-admins`, `clients` and `users` groups are special groups
|
213
|
+
so knife-acl will not allow them to be destroyed.
|
131
214
|
|
132
215
|
## knife acl show OBJECT_TYPE OBJECT_NAME
|
133
216
|
|
134
217
|
Shows the ACL for the specified object. Objects are identified by the
|
135
218
|
combination of their type and name.
|
136
219
|
|
137
|
-
Valid `OBJECT_TYPE`
|
220
|
+
Valid `OBJECT_TYPE` values are
|
138
221
|
|
139
222
|
- clients
|
140
|
-
- groups
|
141
223
|
- containers
|
224
|
+
- cookbooks
|
142
225
|
- data
|
226
|
+
- environments
|
227
|
+
- groups
|
143
228
|
- nodes
|
144
229
|
- roles
|
145
|
-
- cookbooks
|
146
|
-
- environments
|
147
230
|
|
148
231
|
For example, use the following command to obtain the ACL for a node
|
149
232
|
named "web.example.com":
|
150
233
|
|
151
234
|
knife acl show nodes web.example.com
|
152
235
|
|
153
|
-
## knife acl add OBJECT_TYPE OBJECT_NAME
|
236
|
+
## knife acl add group GROUP_NAME OBJECT_TYPE OBJECT_NAME PERMS
|
237
|
+
|
238
|
+
The best practice is to only add groups to ACLs. To enforce this best practice
|
239
|
+
the `knife acl add` command is only able to add groups to ACLs.
|
240
|
+
|
241
|
+
Add `GROUP_NAME` to the `PERMS` access control entry of the `OBJECT_NAME`.
|
242
|
+
Objects are specified by the combination of their type and name.
|
154
243
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
244
|
+
Valid `OBJECT_TYPE` values are
|
245
|
+
|
246
|
+
- clients
|
247
|
+
- containers
|
248
|
+
- cookbooks
|
249
|
+
- data
|
250
|
+
- environments
|
251
|
+
- groups
|
252
|
+
- nodes
|
253
|
+
- roles
|
159
254
|
|
160
|
-
Valid `
|
255
|
+
Valid `PERMS` are:
|
161
256
|
|
162
257
|
- create
|
163
258
|
- read
|
@@ -165,43 +260,151 @@ Valid `PERM`s are:
|
|
165
260
|
- delete
|
166
261
|
- grant
|
167
262
|
|
168
|
-
|
169
|
-
|
263
|
+
Multiple `PERMS` can be given in a single command by separating them
|
264
|
+
with a comma with no extra spaces.
|
265
|
+
|
266
|
+
For example, use the following command to give the superusers group
|
267
|
+
the ability to delete and update the node called "web.example.com":
|
268
|
+
|
269
|
+
knife acl add group superusers nodes web.example.com delete,update
|
270
|
+
|
271
|
+
## knife acl bulk add group GROUP_NAME OBJECT_TYPE REGEX PERMS
|
272
|
+
|
273
|
+
The best practice is to only add groups to ACLs. To enforce this best practice
|
274
|
+
the `knife acl bulk add` command is only able to add groups to ACLs.
|
275
|
+
|
276
|
+
Add `GROUP_NAME` to the `PERMS` access control entry for each object in a
|
277
|
+
set of objects of `OBJECT_TYPE`.
|
278
|
+
|
279
|
+
The set of objects are specified by matching the objects' names with the
|
280
|
+
given REGEX regular expression surrounded by quotes.
|
281
|
+
|
282
|
+
See the `knife acl add` documentation above for valid `OBJECT_TYPE` and `PERMS` values.
|
283
|
+
|
284
|
+
Appending `-y` or `--yes` to the `knife acl bulk add` command will run the command
|
285
|
+
without any prompts for confirmation.
|
286
|
+
|
287
|
+
For example, use the following command to give the superusers group the ability to
|
288
|
+
delete and update all nodes matching the regular expression 'WIN-.*':
|
289
|
+
|
290
|
+
knife acl bulk add group superusers nodes 'WIN-.*' delete,update --yes
|
291
|
+
|
292
|
+
## knife acl remove MEMBER_TYPE MEMBER_NAME OBJECT_TYPE OBJECT_NAME PERMS
|
293
|
+
|
294
|
+
Remove `MEMBER_NAME` from the `PERMS` access control entry of `OBJECT_NAME`.
|
295
|
+
Objects are specified by the combination of their type and name.
|
296
|
+
|
297
|
+
Valid `MEMBER_TYPE` values are
|
298
|
+
|
299
|
+
- client
|
300
|
+
- group
|
301
|
+
- user
|
302
|
+
|
303
|
+
Valid `OBJECT_TYPE` values are
|
304
|
+
|
305
|
+
- clients
|
306
|
+
- containers
|
307
|
+
- cookbooks
|
308
|
+
- data
|
309
|
+
- environments
|
310
|
+
- groups
|
311
|
+
- nodes
|
312
|
+
- roles
|
313
|
+
|
314
|
+
Valid `PERMS` are:
|
315
|
+
|
316
|
+
- create
|
317
|
+
- read
|
318
|
+
- update
|
319
|
+
- delete
|
320
|
+
- grant
|
321
|
+
|
322
|
+
Multiple `PERMS` can be given in a single command by separating them
|
323
|
+
with a comma with no extra spaces.
|
324
|
+
|
325
|
+
For example, use the following command to remove the superusers group from the delete and
|
326
|
+
update access control entries for the node called "web.example.com":
|
327
|
+
|
328
|
+
knife acl remove group superusers nodes web.example.com delete,update
|
329
|
+
|
330
|
+
## knife acl bulk remove MEMBER_TYPE MEMBER_NAME OBJECT_TYPE REGEX PERMS
|
331
|
+
|
332
|
+
Remove `MEMBER_NAME` from the `PERMS` access control entry for each object in a
|
333
|
+
set of objects of `OBJECT_TYPE`.
|
334
|
+
|
335
|
+
The set of objects are specified by matching the objects' names with the
|
336
|
+
given REGEX regular expression surrounded by quotes.
|
337
|
+
|
338
|
+
See the `knife acl remove` documentation above for valid `MEMBER_TYPE`, `OBJECT_TYPE` and `PERMS` values.
|
339
|
+
|
340
|
+
Appending `-y` or `--yes` to the `knife acl bulk add` command will run the command
|
341
|
+
without any prompts for confirmation.
|
342
|
+
|
343
|
+
For example, use the following command to remove the superusers group from the delete and
|
344
|
+
update access control entries for all nodes matching the regular expression 'WIN-.*':
|
345
|
+
|
346
|
+
knife acl bulk remove group superusers nodes 'WIN-.*' delete,update --yes
|
347
|
+
|
348
|
+
## Default Permissions for Containers
|
170
349
|
|
171
|
-
|
350
|
+
The following commands will set the default permissions for the
|
351
|
+
admins, clients and users groups on all containers. These can
|
352
|
+
be helpful if you need to restore container permissions back to their
|
353
|
+
default values.
|
172
354
|
|
173
|
-
|
355
|
+
```
|
356
|
+
knife acl add group admins containers clients create,read,update,delete,grant
|
357
|
+
knife acl remove group clients containers clients create,read,update,delete,grant
|
358
|
+
knife acl add group users containers clients read,delete
|
359
|
+
knife acl remove group users containers clients create,update,grant
|
174
360
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
361
|
+
knife acl add group admins containers cookbooks create,read,update,delete,grant
|
362
|
+
knife acl add group clients containers cookbooks read
|
363
|
+
knife acl remove group clients containers cookbooks create,update,delete,grant
|
364
|
+
knife acl add group users containers cookbooks create,read,update,delete
|
365
|
+
knife acl remove group users containers cookbooks grant
|
180
366
|
|
181
|
-
|
182
|
-
|
367
|
+
knife acl add group admins containers data create,read,update,delete,grant
|
368
|
+
knife acl add group clients containers data read
|
369
|
+
knife acl remove group clients containers data create,update,delete,grant
|
370
|
+
knife acl add group users containers data create,read,update,delete
|
371
|
+
knife acl remove group users containers data grant
|
183
372
|
|
184
|
-
|
373
|
+
knife acl add group admins containers environments create,read,update,delete,grant
|
374
|
+
knife acl add group clients containers environments read
|
375
|
+
knife acl remove group clients containers environments create,update,delete,grant
|
376
|
+
knife acl add group users containers environments create,read,update,delete
|
377
|
+
knife acl remove group users containers environments grant
|
185
378
|
|
379
|
+
knife acl add group admins containers nodes create,read,update,delete,grant
|
380
|
+
knife acl add group clients containers nodes create,read
|
381
|
+
knife acl remove group clients containers nodes update,delete,grant
|
382
|
+
knife acl add group users containers nodes create,read,update,delete
|
383
|
+
knife acl remove group users containers nodes grant
|
186
384
|
|
187
|
-
|
385
|
+
knife acl add group admins containers roles create,read,update,delete,grant
|
386
|
+
knife acl add group clients containers roles read
|
387
|
+
knife acl remove group clients containers roles create,update,delete,grant
|
388
|
+
knife acl add group users containers roles create,read,update,delete
|
389
|
+
knife acl remove group users containers roles grant
|
188
390
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
391
|
+
knife acl add group admins containers sandboxes create,read,update,delete,grant
|
392
|
+
knife acl remove group clients containers sandboxes create,read,update,delete,grant
|
393
|
+
knife acl add group users containers sandboxes create
|
394
|
+
knife acl remove group users containers sandboxes read,update,delete,grant
|
395
|
+
```
|
194
396
|
|
195
397
|
## LICENSE
|
196
398
|
|
197
399
|
Unless otherwise specified all works in this repository are
|
198
400
|
|
199
|
-
Copyright 2013
|
401
|
+
Copyright 2013-2015 Chef Software, Inc.
|
200
402
|
|
201
403
|
|||
|
202
404
|
| ------------- |-------------:|
|
203
|
-
| Author |Seth Falcon (seth@
|
204
|
-
|
|
405
|
+
| Author |Seth Falcon (seth@chef.io)|
|
406
|
+
| Author |Jeremiah Snapp (jeremiah@chef.io)|
|
407
|
+
| Copyright |Copyright (c) 2013-2015 Chef Software, Inc.|
|
205
408
|
| License |Apache License, Version 2.0|
|
206
409
|
|
207
410
|
Licensed under the Apache License, Version 2.0 (the "License");
|
data/lib/chef/knife/acl_add.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Steven Danna (steve@opscode.com)
|
3
|
-
#
|
3
|
+
# Author:: Jeremiah Snapp (jeremiah@chef.io)
|
4
|
+
# Copyright:: Copyright 2011--2015 Chef Software, Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
6
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -19,45 +20,33 @@
|
|
19
20
|
module OpscodeAcl
|
20
21
|
class AclAdd < Chef::Knife
|
21
22
|
category "OPSCODE HOSTED CHEF ACCESS CONTROL"
|
22
|
-
banner "knife acl add OBJECT_TYPE OBJECT_NAME
|
23
|
-
|
24
|
-
attr_reader :object_type, :object_name, :perm, :actor_type, :actor_name
|
23
|
+
banner "knife acl add MEMBER_TYPE MEMBER_NAME OBJECT_TYPE OBJECT_NAME PERMS"
|
25
24
|
|
26
25
|
deps do
|
27
26
|
include OpscodeAcl::AclBase
|
28
27
|
end
|
29
28
|
|
30
29
|
def run
|
31
|
-
|
30
|
+
member_type, member_name, object_type, object_name, perms = name_args
|
32
31
|
|
33
|
-
if name_args.length
|
32
|
+
if name_args.length != 5
|
34
33
|
show_usage
|
35
|
-
ui.fatal "You must specify the
|
34
|
+
ui.fatal "You must specify the member type [group], member name, object type, object name and perms"
|
36
35
|
exit 1
|
37
36
|
end
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
when "client"
|
44
|
-
add_actor_to_ace!(actor_name, ace)
|
45
|
-
when "group"
|
46
|
-
add_group_to_ace!(actor_name, ace)
|
47
|
-
when "users"
|
48
|
-
# Not Implemented yet, we shouldn't get here.
|
38
|
+
unless member_type == 'group'
|
39
|
+
ui.fatal "ERROR: To enforce best practice, knife-acl can only add a group to an ACL."
|
40
|
+
ui.fatal " See the knife-acl README for more information."
|
41
|
+
exit 1
|
49
42
|
end
|
43
|
+
validate_perm_type!(perms)
|
44
|
+
validate_member_name!(member_name)
|
45
|
+
validate_object_name!(object_name)
|
46
|
+
validate_object_type!(object_type)
|
47
|
+
validate_member_exists!(member_type, member_name)
|
50
48
|
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
def add_group_to_ace!(name, ace)
|
55
|
-
ace['groups'] << name unless ace['groups'].include?(name)
|
56
|
-
end
|
57
|
-
|
58
|
-
def add_actor_to_ace!(name, ace)
|
59
|
-
ace['actors'] << name unless ace['actors'].include?(name)
|
49
|
+
add_to_acl!(member_type, member_name, object_type, object_name, perms)
|
60
50
|
end
|
61
|
-
|
62
51
|
end
|
63
52
|
end
|