Configuring a Bucket ACL
Function
You can configure a bucket ACL when creating a bucket or call this API to configure a bucket ACL after the bucket is created. For more information about configuring bucket ACLs, see Configuring a Bucket ACL.
For details about how to use bucket ACLs to manage permissions, see the permission control in the OBS Permission Configuration Guide.
Constraints
- A bucket ACL supports a maximum of 100 grants.
- This API enforces idempotent overwrites. A PUT request with a new bucket ACL will overwrite the existing one. To modify or delete a bucket ACL, submit the desired ACL via PUT.
Authorization
To call this API, you must be the bucket owner or have the permission to configure a bucket ACL. You are advised to use IAM or bucket policies for authorization. For details about OBS authorization methods, see Differences Between OBS Permissions Control Methods.
- If you use IAM for authorization, you need to use either role/policy-based authorization or identity policy-based authorization and configure the required permissions:
- If you use role/policy-based authorization (IAM v3 APIs in the old IAM version), you must have the obs:bucket:PutBucketAcl permission. For details, see Creating a Custom IAM Policy.
- If you use identity policy-based authorization (IAM v5 APIs in the new IAM version), you must have the obs:bucket:putBucketAcl permission, as shown in the following table. For details, see Creating a Custom IAM Identity Policy.
Action
Access Level
Resource Type (*: Required)
Dependencies
obs:bucket:putBucketAcl
Permission_management
bucket *
-
-
-
- obs:EpochTime
- obs:SourceIp
- obs:TlsVersion
- obs:CustomDomain
- obs:x-obs-acl
- If you use bucket policies for authorization, you must have the obs:bucket:PutBucketAcl permission. For details, see Creating a Custom Bucket Policy.
URI
PUT /
Calling Method
For details, see Calling APIs. Before calling this API, calculate the API signature and add it to the request.
You can debug this API in API Explorer.
Request Syntax
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | PUT /?acl HTTP/1.1 Host: bucketname.obs.region.myhuaweicloud.com Date: date Authorization: authorization Content-Type: application/xml Content-Length: length <AccessControlPolicy xmlns="http://obs.myhwclouds.com/doc/2015-06-30/"> <Owner> <ID>ID</ID> </Owner> <AccessControlList> <Grant> <Grantee> <ID>domainId</ID> </Grantee> <Permission>permission</Permission> <Delivered>false</Delivered> </Grant> </AccessControlList> </AccessControlPolicy> |
URI Parameters
This request contains no parameters.
Request Headers
You can change the ACL of a bucket by using the header settings. Each ACL configured with the header setting has a set of predefined grantees and authorized permissions. If you want to authorize access permissions by adding the header to a request, you must add the following header and specify the value.
| Header | Type | Mandatory | Description |
|---|---|---|---|
| x-obs-acl | String | No | Definition Uses the canned ACL for a bucket. Constraints N/A Range
When public-read-delivered or public-read-write-delivered is used, the Delivered attribute of the ACL will be automatically set to true. For details about each policy, see "Configuring an ACL Using Header Fields" in ACLs. Default Value private |
Request Body
This request includes ACL information in elements to update an ACL. Table 2 describes the elements.
| Element | Type | Mandatory | Description |
|---|---|---|---|
| Owner | XML | Yes | Definition Bucket owner information, which is the parent node of ID (bucket owner's account ID). Constraints N/A Range N/A Default Value N/A |
| ID | String | Yes | Definition Account ID of the bucket owner. Constraints N/A Range N/A Default Value N/A |
| AccessControlList | XML | Yes | Definition Access control list, which is the parent node of Grant. Constraints N/A Range N/A Default Value N/A |
| Grant | XML | No | Definition Identifies users and user permissions. It is the parent node of Grantee, Permission, and Delivered. If Grant is not set, AccessControlList is an empty list. Constraints A single bucket ACL can contain no more than 100 grants. Range N/A Default Value N/A |
| Grantee | XML | No | Definition Records user information. It is the parent node of ID (authorized user's account ID). Specify either ID or Canned. Constraints N/A Range N/A Default Value N/A |
| ID | String | No | Definition Account ID of the authorized user. Constraints Specify either ID or Canned. Use ID to specify a specific user and Canned to specify everyone. Range N/A Default Value N/A |
| Canned | String | No | Definition Grants permissions to everyone. Constraints Specify either ID or Canned. Use ID to specify a specific user and Canned to specify everyone. Range N/A Default Value N/A |
| Permission | String | Yes | Definition Permissions to be granted. For details, see access permissions controlled by a bucket ACL. Constraints N/A Range
Default Value N/A |
| Delivered | Boolean | No | Definition Indicates whether the bucket ACL can be inherited by objects. When Delivered is set to true, the bucket ACL can be applied to objects in the bucket. Constraints N/A Range
Default Value false |
Response Syntax
1 2 3 | HTTP/1.1 status_code Date: date Content-Length: length |
Response Headers
This response uses common headers. For details, see Table 1.
Response Body
This response does not contain a response body.
Error Responses
Table 3 describes possible special errors in this request.
| Error Code | Description | HTTP Status Code |
|---|---|---|
| UnexpectedContent | The request contains both the ACL header and message body. | 400 Bad Request |
| MissingSecurityHeader | The request does not include any of the following: x-amz-acl header, grant header, or message body. | 400 Bad Request |
| MalformedACLError | Invalid ACL XML format. | 400 Bad Request |
| EntityTooLarge | The ACL request body size exceeds the upper limit. | 400 Bad Request |
| InvalidArgument | Invalid argument in the ACL. | 400 Bad Request |
Refer to Error Code Overview for all other errors.
Sample Request
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | PUT /?acl HTTP/1.1 User-Agent: curl/7.29.0 Host: examplebucket.obs.region.myhuaweicloud.com Accept: */* Date: Wed, 01 Jul 2015 02:37:22 GMT Authorization: OBS H4IPJX0TQTHTHEBQQCEC:iqSPeUBl66PwXDApxjRKk6hlcN4= Content-Length: 727 <AccessControlPolicy xmlns="http://obs.ap-southeast-1.myhuaweicloud.com/doc/2015-06-30/"> <Owner> <ID>b4bf1b36d9ca43d984fbcb9491b6fce9</ID> </Owner> <AccessControlList> <Grant> <Grantee> <ID>b4bf1b36d9ca43d984fbcb9491b6fce9</ID> </Grantee> <Permission>FULL_CONTROL</Permission> <Delivered>false</Delivered> </Grant> <Grant> <Grantee> <ID>783fc6652cf246c096ea836694f71855</ID> </Grantee> <Permission>READ</Permission> <Delivered>false</Delivered> </Grant> <Grant> <Grantee> <Canned>Everyone</Canned> </Grantee> <Permission>READ_ACP</Permission> <Delivered>false</Delivered> </Grant> </AccessControlList> </AccessControlPolicy> |
Sample Response
1 2 3 4 5 6 | HTTP/1.1 200 OK Server: OBS x-obs-request-id: BF2600000164361F2954B4D063164704 x-obs-id-2: 32AAAQAAEAABSAAgAAEAABAAAQAAEAABCT78HTIBuhe0FbtSptrb/akwELtwyPKs Date: Wed, 01 Jul 2015 02:37:22 GMT Content-Length: 0 |
Sample Request: Specifying Access Permissions Using Headers
PUT /?acl HTTP/1.1 Authorization: OBS H4IPJX0TQTHTHEBQQCEC:iqSPeUBl66PwXDApxjRKk6hlcN4= User-Agent: curl/7.29.0 Host: examplebucket.obs.region.myhuaweicloud.com x-obs-acl: private Date: Wed, 01 Jul 2015 02:37:22 GMT Content-Type: application/xml
Sample Response: Specifying Access Permissions Using Headers
HTTP/1.1 200 OK x-obs-id-2: 32AAAQAAEAABSAAgAAEAABAAAQAAEAABCSmpL2dv6zZLM2HmUrXKTAi258MPqmrp x-obs-request-id: 0000018A2A73AF59D3085C8F8ABF0C65 Server: OBS Content-Length: 0 Date: Wed, 01 Jul 2015 02:37:22 GMT
Using SDKs to Call APIs
You are advised to use OBS SDKs to call APIs. SDKs encapsulate APIs to simplify development. You can call SDK API functions to access OBS without manually calculating signatures.
Helpful Links
- To use obsutil to configure bucket ACLs, see Setting Bucket Properties.
- To use OBS Browser+ to configure bucket ACLs, see Configuring a Bucket ACL.
- For more information about configuring bucket ACLs, see Configuring a Bucket ACL.
- For details about the billing items involved in API operations, see Billing Items.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot