Bucket Policies and Object Policies
Bucket Owner and Object Owner
The owner of a bucket is the account that created the bucket. If the bucket is created by an IAM user under the account, the bucket owner is the account instead of the IAM user.
The owner of an object is the account that uploads the object, who may not be the owner of the bucket to which the object belongs. For example, account B is granted the permission to access a bucket of account A, and account B uploads a file to the bucket. In that case, instead of the bucket owner account A, account B is the owner of the object.
Bucket Policy
A bucket policy is attached to a bucket and objects in the bucket. By leveraging bucket policies, the owner of a bucket can authorize IAM users or other accounts the permissions to operate the bucket and objects in the bucket.
Creating buckets and obtaining the bucket list are service level operations that should be configured by granting IAM permissions.
Bucket Policy Application Scenarios:
- If no IAM permissions are used for access permission control and you want to authorize other accounts the permission to access your OBS resources, you can use bucket policies to authorize such permissions.
- You can configure different bucket policies to grant IAM users different access permissions to different buckets.
- You can also use bucket policies to grant other accounts the permissions to access your buckets.
Bucket policy template:
OBS Console provides bucket policy templates for six typical scenarios. You can use the templates to quickly configure bucket policies.
When using a template to create a bucket policy, you need to specify principals (authorized users) and resources, or you can modify the template settings, including principal, resources, actions, and conditions.
| Template Name | Principal | Resource | Template Action |
|---|---|---|---|
| Bucket read-only | To be specified | The bucket and all objects in the bucket | Allows specified users to perform the following operations on the current bucket and all objects in the bucket: Get* (all get operations) List* (all list operations) HeadBucket (checking whether a bucket exists) |
| Bucket read and write | To be specified | The bucket and all objects in the bucket | Allows specified users to perform all operations excluding the following ones on the current bucket and all objects in the bucket: DeleteBucket (deleting the bucket) PutBucketPolicy (configuring bucket policies) PutBucketAcl (configuring the bucket ACL) |
| Directory read-only | To be specified | To be specified (You need to specify an object name prefix.) | Allows specified users to perform the following operations on the current bucket and specified objects in the bucket: ListBucket (listing objects in a bucket and obtaining the bucket metadata) HeadBucket (checking whether a bucket exists) GetBucketLocation (getting the bucket location) ListBucketVersions (listing object versions in the bucket) GetObject (obtaining object content and metadata) RestoreObject (restoring objects from Archive storage) GetObjectAcl (obtaining object ACL information) GetObjectVersion (obtaining the content and metadata of a specified object version) GetObjectVersionAcl (obtaining the ACL information of a specified object version) |
| Directory read and writ | To be specified | To be specified (You need to specify an object name prefix.) | Allows specified users to perform the following operations on the current bucket and specified objects in the bucket: ListBucket (listing objects in a bucket and obtaining the bucket metadata) HeadBucket (checking whether a bucket exists) GetBucketLocation (getting the bucket location) ListBucketVersions (listing object versions in the bucket) ListBucketMultipartUploads (listing multipart upload tasks) GetObject (obtaining object content and metadata) PutObject (PUT upload, POST upload, multipart upload, initialization of uploaded parts, and merging of parts) RestoreObject (restoring objects from Archive storage) GetObjectAcl (obtaining object ACL information) PutObjectAcl (configuring object ACL) GetObjectVersion (obtaining the content and metadata of a specified object version) GetObjectVersionAcl (obtaining the ACL information of a specified object version) AbortMultipartUpload (canceling multipart upload tasks) ListMultipartUploadParts (listing uploaded parts) ModifyObjectMetaData (modifying object metadata) |
| Public read | Anonymous user (all Internet users) | The bucket and all objects in the bucket | Allows anonymous users to perform the following operations on the current bucket and all objects in the bucket: ListBucket (listing objects in a bucket and obtaining the bucket metadata) HeadBucket (checking whether a bucket exists) GetBucketLocation (getting the bucket location) ListBucketVersions (listing object versions in the bucket) GetObject (obtaining object content and metadata) RestoreObject (restoring objects from Archive storage) GetObjectVersion (obtaining the content and metadata of a specified object version) |
| Public read and write | Anonymous user (all Internet users) | The bucket and all objects in the bucket | Allows anonymous users to perform the following operations on the current bucket and all objects in the bucket: ListBucket (listing objects in a bucket and obtaining the bucket metadata) HeadBucket (checking whether a bucket exists) GetBucketLocation (getting the bucket location) ListBucketVersions (listing object versions in the bucket) ListBucketMultipartUploads (listing multipart upload tasks) GetObject (obtaining object content and metadata) PutObject (PUT upload, POST upload, multipart upload, initialization of uploaded parts, and merging of parts) RestoreObject (restoring objects from Archive storage) GetObjectAcl (obtaining object ACL information) PutObjectAcl (configuring object ACL) GetObjectVersion (obtaining the content and metadata of a specified object version) GetObjectVersionAcl (obtaining the ACL information of a specified object version) AbortMultipartUpload (canceling multipart upload tasks) ListMultipartUploadParts (listing uploaded parts) ModifyObjectMetaData (modifying object metadata) |
Custom Bucket Policy:
You can also customize a bucket policy based on your service requirements. A custom bucket policy consists of five basic elements: effect, principal, resource, action, and condition. For details, see Bucket Policy Parameters.
Object Policy
Object policies apply to objects in a bucket. A bucket policy is applicable to a set of objects (with the same object name prefix) or to all objects (specified by an asterisk *) in the bucket. To configure an object policy, select an object, and then configure the policy directly for the object.
Object policy template:
OBS Console provides object policy templates for four typical scenarios. You can use the templates to quickly configure object policies.
When using a template to create an object policy, you need to specify principals (authorized users), or you can modify the template settings, including the principal, actions, and conditions. The resource is the object for which the policy needs to be configured. This resource is automatically specified by the system and does not need to be modified.
| Template Name | Principal | Resource | Template Action |
|---|---|---|---|
| Read-only | To be specified | The selected object, which is automatically specified by the system and does not need to be modified. | Allows specified users to perform the following operations on the selected object: GetObject (obtaining object content and metadata) GetObjectVersion (obtaining the content and metadata of a specific object version) GetObjectVersionAcl (obtaining the ACL of a specific object version) GetObjectAcl (obtaining object ACL information) RestoreObject (restoring Archive objects) |
| Read and write | To be specified | The selected object, which is automatically specified by the system and does not need to be modified. | Allows specified users to perform the following operations on the selected object: PutObject (PUT upload, POST upload, multipart upload, initialization of uploaded parts, and merging of parts) GetObject (obtaining object content and metadata) GetObjectVersion (obtaining the content and metadata of a specific object version) ModifyObjectMetaData (modifying object metadata) ListMultipartUploadParts (listing uploaded parts) AbortMultipartUpload (canceling multipart upload tasks) GetObjectVersionAcl (obtaining the ACL of a specific object version) GetObjectAcl (obtaining object ACL information) PutObjectAcl (configuring an object ACL) RestoreObject (restoring Archive objects) |
| Public read | Anonymous user (all Internet users) | The selected object, which is automatically specified by the system and does not need to be modified. | Allows anonymous users to perform the following operations on the selected object: GetObject (obtaining object content and metadata) RestoreObject (restoring Archive objects) GetObjectVersion (obtaining the content and metadata of a specific object version) |
| Public read and write | Anonymous user (all Internet users) | The selected object, which is automatically specified by the system and does not need to be modified. | Allows anonymous users to perform the following operations on the selected object: PutObject (PUT upload, POST upload, multipart upload, initialization of uploaded parts, and merging of parts) GetObject (obtaining object content and metadata) ModifyObjectMetaData (modifying object metadata) ListMultipartUploadParts (listing uploaded parts) AbortMultipartUpload (canceling multipart upload tasks) RestoreObject (restoring Archive objects) GetObjectVersion (obtaining the content and metadata of a specific object version) PutObjectAcl (configuring an object ACL) GetObjectVersionAcl (obtaining the ACL of a specific object version) GetObjectAcl (obtaining object ACL information) |
Custom Object Policy
You can also customize an object policy based on your service requirements. A custom object policy consists of five basic elements: effect, principal, resources, actions, and conditions, similar to a bucket policy. For details, see Bucket Policy Parameters. The resource is the selected object and is automatically configured by the system.
Last Article: IAM Permissions
Next Article: Bucket ACLs and Object ACLs
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.