Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(998)

Side by Side Diff: gslib/addlhelp/acls.py

Issue 698893003: Update checked in version of gsutil to version 4.6 (Closed) Base URL: http://dart.googlecode.com/svn/third_party/gsutil/
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gslib/addlhelp/__init__.py ('k') | gslib/addlhelp/anon.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # -*- coding: utf-8 -*-
1 # Copyright 2012 Google Inc. All Rights Reserved. 2 # Copyright 2012 Google Inc. All Rights Reserved.
2 # 3 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License. 5 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at 6 # You may obtain a copy of the License at
6 # 7 #
7 # http://www.apache.org/licenses/LICENSE-2.0 8 # http://www.apache.org/licenses/LICENSE-2.0
8 # 9 #
9 # Unless required by applicable law or agreed to in writing, software 10 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and 13 # See the License for the specific language governing permissions and
13 # limitations under the License. 14 # limitations under the License.
15 """Additional help about Access Control Lists."""
14 16
15 from gslib.help_provider import HELP_NAME 17 from __future__ import absolute_import
16 from gslib.help_provider import HELP_NAME_ALIASES 18
17 from gslib.help_provider import HELP_ONE_LINE_SUMMARY
18 from gslib.help_provider import HelpProvider 19 from gslib.help_provider import HelpProvider
19 from gslib.help_provider import HELP_TEXT
20 from gslib.help_provider import HelpType
21 from gslib.help_provider import HELP_TYPE
22 20
23 _detailed_help_text = (""" 21 _DETAILED_HELP_TEXT = ("""
24 <B>OVERVIEW</B> 22 <B>OVERVIEW</B>
25 Access Control Lists (ACLs) allow you to control who can read and write 23 Access Control Lists (ACLs) allow you to control who can read and write
26 your data, and who can read and write the ACLs themselves. 24 your data, and who can read and write the ACLs themselves.
27 25
28 If not specified at the time an object is uploaded (e.g., via the gsutil cp 26 If not specified at the time an object is uploaded (e.g., via the gsutil cp
29 -a option), objects will be created with a default object ACL set on the 27 -a option), objects will be created with a default object ACL set on the
30 bucket (see "gsutil help defacl"). You can replace the ACL on an object 28 bucket (see "gsutil help defacl"). You can replace the ACL on an object
31 or bucket using the "gsutil acl set" command, or 29 or bucket using the "gsutil acl set" command, or
32 modify the existing ACL using the "gsutil acl ch" command (see "gsutil help 30 modify the existing ACL using the "gsutil acl ch" command (see "gsutil help
33 acl"). 31 acl").
34 32
35 33
36 <B>BUCKET VS OBJECT ACLS</B> 34 <B>BUCKET VS OBJECT ACLS</B>
37 In Google Cloud Storage, the bucket ACL works as follows: 35 In Google Cloud Storage, the bucket ACL works as follows:
38 36
39 - Users granted READ access are allowed to list the bucket contents. 37 - Users granted READ access are allowed to list the bucket contents.
40 38
41 - Users granted WRITE access are allowed READ access and also are 39 - Users granted WRITE access are allowed READ access and also are
42 allowed to write and delete objects in that bucket -- including 40 allowed to write and delete objects in that bucket -- including
43 overwriting previously written objects. 41 overwriting previously written objects.
44 42
45 - Users granted FULL_CONTROL access are allowed WRITE access and also 43 - Users granted OWNER access are allowed WRITE access and also
46 are allowed to read and write the bucket's ACL. 44 are allowed to read and write the bucket's ACL.
47 45
48 The object ACL works as follows: 46 The object ACL works as follows:
49 47
50 - Users granted READ access are allowed to read the object's data and 48 - Users granted READ access are allowed to read the object's data and
51 metadata. 49 metadata.
52 50
53 - Users granted FULL_CONTROL access are allowed READ access and also 51 - Users granted OWNER access are allowed READ access and also
54 are allowed to read and write the object's ACL. 52 are allowed to read and write the object's ACL.
55 53
56 A couple of points are worth noting, that sometimes surprise users: 54 A couple of points are worth noting, that sometimes surprise users:
57 55
58 1. There is no WRITE access for objects; attempting to set an ACL with WRITE 56 1. There is no WRITE access for objects; attempting to set an ACL with WRITE
59 permission for an object will result in an error. 57 permission for an object will result in an error.
60 58
61 2. The bucket ACL plays no role in determining who can read objects; only the 59 2. The bucket ACL plays no role in determining who can read objects; only the
62 object ACL matters for that purpose. This is different from how things 60 object ACL matters for that purpose. This is different from how things
63 work in Linux file systems, where both the file and directory permission 61 work in Linux file systems, where both the file and directory permission
64 control file read access. It also means, for example, that someone with 62 control file read access. It also means, for example, that someone with
65 FULL_CONTROL over the bucket may not have read access to objects in 63 OWNER over the bucket may not have read access to objects in
66 the bucket. This is by design, and supports useful cases. For example, 64 the bucket. This is by design, and supports useful cases. For example,
67 you might want to set up bucket ownership so that a small group of 65 you might want to set up bucket ownership so that a small group of
68 administrators have FULL_CONTROL on the bucket (with the ability to 66 administrators have OWNER on the bucket (with the ability to
69 delete data to control storage costs), but not grant those users read 67 delete data to control storage costs), but not grant those users read
70 access to the object data (which might be sensitive data that should 68 access to the object data (which might be sensitive data that should
71 only be accessed by a different specific group of users). 69 only be accessed by a different specific group of users).
72 70
73 71
74 <B>CANNED ACLS</B> 72 <B>CANNED ACLS</B>
75 The simplest way to set an ACL on a bucket or object is using a "canned 73 The simplest way to set an ACL on a bucket or object is using a "canned
76 ACL". The available canned ACLs are: 74 ACL". The available canned ACLs are:
77 75
78 project-private 76 project-private
79 Gives permission to the project team based on their roles. Anyone who is 77 Gives permission to the project team based on their roles. Anyone who is
80 part of the team has READ permission, and project owners and project editors 78 part of the team has READ permission, and project owners and project editors
81 have FULL_CONTROL permission. This is the default ACL for newly created 79 have OWNER permission. This is the default ACL for newly created
82 buckets. This is also the default ACL for newly created objects unless the 80 buckets. This is also the default ACL for newly created objects unless the
83 default object ACL for that bucket has been changed. For more details see 81 default object ACL for that bucket has been changed. For more details see
84 "gsutil help projects". 82 "gsutil help projects".
85 83
86 private 84 private
87 Gives the requester (and only the requester) FULL_CONTROL permission for a 85 Gives the requester (and only the requester) OWNER permission for a
88 bucket or object. 86 bucket or object.
89 87
90 public-read 88 public-read
91 Gives the requester FULL_CONTROL permission and gives all users READ 89 Gives the requester OWNER permission and gives all users READ
92 permission. When you apply this to an object, anyone on the Internet can 90 permission. When you apply this to an object, anyone on the Internet can
93 read the object without authenticating. 91 read the object without authenticating.
94 92
95 NOTE: By default, publicly readable objects are served with a Cache-Control 93 NOTE: By default, publicly readable objects are served with a Cache-Control
96 header allowing such objects to be cached for 3600 seconds. If you need to 94 header allowing such objects to be cached for 3600 seconds. If you need to
97 ensure that updates become visible immediately, you should set a 95 ensure that updates become visible immediately, you should set a
98 Cache-Control header of "Cache-Control:private, max-age=0, no-transform" on 96 Cache-Control header of "Cache-Control:private, max-age=0, no-transform" on
99 such objects. For help doing this, see 'gsutil help setmeta'. 97 such objects. For help doing this, see 'gsutil help setmeta'.
100 98
101 public-read-write 99 public-read-write
102 Gives the requester FULL_CONTROL permission and gives all users READ and 100 Gives the requester OWNER permission and gives all users READ and
103 WRITE permission. This ACL applies only to buckets. 101 WRITE permission. This ACL applies only to buckets.
104 102
105 authenticated-read 103 authenticated-read
106 Gives the requester FULL_CONTROL permission and gives all authenticated 104 Gives the requester OWNER permission and gives all authenticated
107 Google account holders READ permission. 105 Google account holders READ permission.
108 106
109 bucket-owner-read 107 bucket-owner-read
110 Gives the requester FULL_CONTROL permission and gives the bucket owner READ 108 Gives the requester OWNER permission and gives the bucket owner READ
111 permission. This is used only with objects. 109 permission. This is used only with objects.
112 110
113 bucket-owner-full-control 111 bucket-owner-full-control
114 Gives the requester FULL_CONTROL permission and gives the bucket owner 112 Gives the requester OWNER permission and gives the bucket owner
115 FULL_CONTROL permission. This is used only with objects. 113 OWNER permission. This is used only with objects.
116 114
117 115
118 <B>ACL XML</B> 116 <B>ACL JSON</B>
119 When you use a canned ACL, it is translated into an XML representation 117 When you use a canned ACL, it is translated into an JSON representation
120 that can later be retrieved and edited to specify more fine-grained 118 that can later be retrieved and edited to specify more fine-grained
121 detail about who can read and write buckets and objects. By running 119 detail about who can read and write buckets and objects. By running
122 the "gsutil acl get" command you can retrieve the ACL XML, and edit it to 120 the "gsutil acl get" command you can retrieve the ACL JSON, and edit it to
123 customize the permissions. 121 customize the permissions.
124 122
125 As an example, if you create an object in a bucket that has no default 123 As an example, if you create an object in a bucket that has no default
126 object ACL set and then retrieve the ACL on the object, it will look 124 object ACL set and then retrieve the ACL on the object, it will look
127 something like this: 125 something like this:
128 126
129 <AccessControlList> 127 [
130 <Owner> 128 {
131 <ID> 129 "entity": "group-00b4903a9740e42c29800f53bd5a9a62a2f96eb3f64a4313a115df3f3 a776bf7",
132 00b4903a9740e42c29800f53bd5a9a62a2f96eb3f64a4313a115df3f3a776bf7 130 "entityId": "00b4903a9740e42c29800f53bd5a9a62a2f96eb3f64a4313a115df3f3a776 bf7",
133 </ID> 131 "role": "OWNER"
134 </Owner> 132 },
135 <Entries> 133 {
136 <Entry> 134 "entity": "group-00b4903a977fd817e9da167bc81306489181a110456bb635f466d71cf 90a0d51",
137 <Scope type="GroupById"> 135 "entityId": "00b4903a977fd817e9da167bc81306489181a110456bb635f466d71cf90a0 d51",
138 <ID> 136 "role": "OWNER"
139 00b4903a9740e42c29800f53bd5a9a62a2f96eb3f64a4313a115df3f3a776bf7 137 },
140 </ID> 138 {
141 </Scope> 139 "entity": "00b4903a974898cc8fc309f2f2835308ba3d3df1b889d3fc7e33e187d52d8e7 1",
142 <Permission> 140 "entityId": "00b4903a974898cc8fc309f2f2835308ba3d3df1b889d3fc7e33e187d52d8 e71",
143 FULL_CONTROL 141 "role": "READER"
144 </Permission> 142 }
145 </Entry> 143 ]
146 <Entry>
147 <Scope type="GroupById">
148 <ID>
149 00b4903a977fd817e9da167bc81306489181a110456bb635f466d71cf90a0d51
150 </ID>
151 </Scope>
152 <Permission>
153 FULL_CONTROL
154 </Permission>
155 </Entry>
156 <Entry>
157 <Scope type="GroupById">
158 <ID>
159 00b4903a974898cc8fc309f2f2835308ba3d3df1b889d3fc7e33e187d52d8e71
160 </ID>
161 </Scope>
162 <Permission>
163 READ
164 </Permission>
165 </Entry>
166 </Entries>
167 </AccessControlList>
168 144
169 The ACL consists of an Owner element and a collection of Entry elements, 145 The ACL consists collection of elements, each of which specifies an Entity
170 each of which specifies a Scope and a Permission. Scopes are the way you 146 and a Role. Entities are the way you specify an individual or group of
171 specify an individual or group of individuals, and Permissions specify what 147 individuals, and Roles specify what access they're permitted.
172 access they're permitted.
173 148
174 This particular ACL grants FULL_CONTROL to two groups (which means members 149 This particular ACL grants OWNER to two groups (which means members
175 of those groups are allowed to read the object and read and write the ACL), 150 of those groups are allowed to read the object and read and write the ACL),
176 and READ permission to a third group. The project groups are (in order) 151 and READ permission to a third group. The project groups are (in order)
177 the owners group, editors group, and viewers group. 152 the project owners group, editors group, and viewers group.
178 153
179 The 64 digit hex identifiers used in this ACL are called canonical IDs, 154 The 64 digit hex identifiers (following any prefixes like "group-") used in
180 and are used to identify predefined groups associated with the project that 155 this ACL are called canonical IDs. They are used to identify predefined
181 owns the bucket. For more information about project groups, see "gsutil 156 groups associated with the project that owns the bucket: the Project Owners,
182 help projects". 157 Project Editors, and All Project Team Members groups. For more information
158 the permissions and roles of these project groups, see "gsutil help projects".
183 159
184 Here's an example of an ACL specified using the GroupByEmail and GroupByDomain 160 Here's an example of an ACL specified using the group-by-email and
185 scopes: 161 group-by-domain entities:
186 162
187 <AccessControlList> 163 [
188 <Entries> 164 {
189 <Entry> 165 "entity": "group-travel-companion-owners@googlegroups.com"
190 <Permission> 166 "email": "travel-companion-owners@googlegroups.com",
191 FULL_CONTROL 167 "role": "OWNER",
192 </Permission> 168 }
193 <Scope type="GroupByEmail"> 169 {
194 <EmailAddress>travel-companion-owners@googlegroups.com</EmailAddress > 170 "domain": "example.com",
195 </Scope> 171 "entity": "domain-example.com"
196 </Entry> 172 "role": "READER",
197 <Entry> 173 },
198 <Permission> 174 ]
199 READ
200 </Permission>
201 <Scope type="GroupByDomain">
202 <Domain>example.com</Domain>
203 </Scope>
204 </Entry>
205 </Entries>
206 </AccessControlList>
207 175
208 This ACL grants members of an email group FULL_CONTROL, and grants READ 176 This ACL grants members of an email group OWNER, and grants READ
209 access to any user in a domain (which must be a Google Apps for Business 177 access to any user in a domain (which must be a Google Apps for Business
210 domain). By applying email group grants to a collection of objects 178 domain). By applying email group grants to a collection of objects
211 you can edit access control for large numbers of objects at once via 179 you can edit access control for large numbers of objects at once via
212 http://groups.google.com. That way, for example, you can easily and quickly 180 http://groups.google.com. That way, for example, you can easily and quickly
213 change access to a group of company objects when employees join and leave 181 change access to a group of company objects when employees join and leave
214 your company (i.e., without having to individually change ACLs across 182 your company (i.e., without having to individually change ACLs across
215 potentially millions of objects). 183 potentially millions of objects).
216 184
217 185
218 <B>SHARING SCENARIOS</B> 186 <B>SHARING SCENARIOS</B>
219 For more detailed examples how to achieve various useful sharing use 187 For more detailed examples how to achieve various useful sharing use
220 cases see https://developers.google.com/storage/docs/collaboration 188 cases see https://developers.google.com/storage/docs/collaboration
221 """) 189 """)
222 190
223 191
224 class CommandOptions(HelpProvider): 192 class CommandOptions(HelpProvider):
225 """Additional help about Access Control Lists.""" 193 """Additional help about Access Control Lists."""
226 194
227 help_spec = { 195 # Help specification. See help_provider.py for documentation.
228 # Name of command or auxiliary help info for which this help applies. 196 help_spec = HelpProvider.HelpSpec(
229 HELP_NAME : 'acls', 197 help_name='acls',
230 # List of help name aliases. 198 help_name_aliases=[
231 HELP_NAME_ALIASES : ['ACL', 'access control', 'access control list', 199 'ACL', 'access control', 'access control list', 'authorization',
232 'authorization', 'canned', 'canned acl'], 200 'canned', 'canned acl'],
233 # Type of help: 201 help_type='additional_help',
234 HELP_TYPE : HelpType.ADDITIONAL_HELP, 202 help_one_line_summary='Working With Access Control Lists',
235 # One line summary of this help. 203 help_text=_DETAILED_HELP_TEXT,
236 HELP_ONE_LINE_SUMMARY : 'Working With Access Control Lists', 204 subcommand_help_text={},
237 # The full help text. 205 )
238 HELP_TEXT : _detailed_help_text,
239 }
OLDNEW
« no previous file with comments | « gslib/addlhelp/__init__.py ('k') | gslib/addlhelp/anon.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698