Granting Public Read Permissions on a Bucket for Anonymous Users
Scenario
If a bucket needs to be accessed by anonymous users, you can configure a bucket policy and bucket ACL to grant the access permission to anonymous users. The following uses a bucket policy as an example.
Configuration Precautions
The Public Read policy allows any user to read objects in a bucket. Public Read has the following permissions:
- GetObject: downloading objects
- GetObjectVersion: downloading versioned objects
- HeadBucket: checking whether a bucket exists
- ListBucket: listing objects in a bucket, and getting the bucket metadata
When you access a bucket through its domain name, the ListBucket permission allows you to list all objects in the bucket. If you want to restrict this permission to specified users under an account, see Related Scenario: Canceling the ListBucket Permission from the Public Read Policy.
Procedure
- In the navigation pane of OBS Console, choose Buckets.
- In the bucket list, click the bucket name you want to go to the Overview page.
- In the navigation pane, choose Permissions > Bucket Policy.
- On the Bucket Policies page, click Create.
- On the displayed page, locate the row containing Public Read and click Use Policy Template.
- Configure parameters for a bucket policy. Figure 1 Configuring bucket policy parameters
Table 1 Parameter description Parameter
Description
Policy View
Set this parameter based on your own habits. Example: Visual editor.
Policy Name
Name of the custom policy
Policy Content
Retain the default settings.
- After configuring the required parameters, click Next.
- Ensure all the configurations are correct and click Create.
Verification
- After the permission is set, in the Basic Information area of the bucket details page, locate Access Domain Name. Share the URL of the access domain name over the Internet so that all Internet users can access the bucket.
- On the Objects tab page of the bucket, click the target object name and find the object link. Share the object link over the Internet so that all Internet users can access the object.
Related Scenario: Canceling the ListBucket Permission from the Public Read Policy
If you want to restrict the ListBucket permission to specified users under an account, you need to configure another bucket policy.
- In the navigation pane of OBS Console, choose Buckets.
- In the bucket list, click the bucket name you want to go to the Overview page.
- In the navigation pane, choose Permissions > Bucket Policy.
- On the Bucket Policies page, click Create.
- Locate the row containing Custom policy and click Create Custom Policy.
- Configure parameters for a bucket policy. Figure 2 Configuring bucket policy parameters
Table 2 Parameter description Parameter
Description
Policy View
Set this parameter based on your own habits. Example: Visual editor.
Policy Name
Name of the custom policy
Policy Content
- Select Deny.
- Parameters under Principal:
- Principal: Select Current account.
- Sub-user: Select one or more IAM users who are allowed to list objects in the bucket.
- User Policy: Select Exclude specified users.
- Parameters under Principal:
- Principal: Select Other account.
- Account ID: Enter the ID of the account to whom you want to grant the ListBucket permission. You can obtain it from the My Credentials page of the account.
- IAM User ID: Enter the ID of the user to whom you want to grant the ListBucket permission. You can obtain it from the My Credentials page of the account.
- Parameters under Resources:
- Resource: Select Current bucket.
- Resource Policy: Select Include specified resources.
- Parameters under Actions:
- ListBucket
- After configuring the required parameters, click Next.
- Ensure all the configurations are correct and click Create.
Verification: After the permission is set, in the Basic Information area of the bucket details page, locate Access Domain Name. Publish the URL on the Internet, and verify that only specified users can list objects in the bucket.
Last Article: Granting Permissions to Anonymous Users
Next Article: Granting Public Read Permissions on a Specific Directory for Anonymous Users
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.