Updated on 2024-03-04 GMT+08:00

Granting Other Accounts the Read Permission for Certain Objects

Scenario

This case describes how to grant other accounts (excluding IAM users under the account) the read permission for an object or a type of objects in an OBS bucket. For details about how to grant permissions to an IAM user, see Granting IAM Users Under an Account the Access to a Bucket and the Resources in It.

Recommended Configuration

You are advised to use bucket policies to grant permissions to other accounts.

Configuration Precautions

In this case, the preset template Object Read-Only allows other accounts to perform the following actions on specified objects in a bucket:

  • GetObject (to obtain object content and metadata)
  • GetObjectVersion (to obtain the content and metadata of a specified object version)
  • GetObjectVersionAcl (to obtain the ACL of a specified object version)
  • GetObjectAcl (to obtain the object ACL)
  • RestoreObject (to restore objects from Archive storage)

After the configuration is complete, you can read (download) specific objects using APIs or SDKs. However, if you download an object from OBS Console or OBS Browser+, an error is reported indicating that you do not have required permissions.

This is because when you log in to OBS Console or OBS Browser+, the ListAllMyBuckets APi is called to load the bucket list, the ListBucket API is called to load the object list, and some other APIs will also be called on other pages, but your permissions do not cover those APIs. In such case, your access is denied or your operation is not allowed.

Procedure

  1. In the navigation pane of OBS Console, choose Buckets.
  2. In the bucket list, click the bucket name you want to go to the Objects page.
  3. In the navigation pane, choose Permissions > Bucket Policies.
  4. On the Bucket Policies page, click Create.
  5. Choose a policy configuration method you like. Visual Editor is used here.
  6. Configure parameters for a bucket policy.

    Figure 1 Configuring a bucket policy
    Table 1 Parameters for configuring a bucket policy

    Parameter

    Description

    Policy Name

    Enter a policy name.

    Policy content

    Effect

    Select Allow.

    Principals

    • Select Other accounts.
      NOTE:

      You can obtain the account ID and IAM user ID from the My Credentials page.

      Accounts should be configured in the Domain ID/IAM user ID format, with each one on a separate line.

      Account ID/* indicates that permission is granted to all IAM users under the account.

    Resources

    • Select Specified objects.
    • Enter an object name prefix for the resource path.
      NOTE:
      • You can click Add to specify multiple resource paths.
      • You can specify a specific object, an object set, or a directory. * indicates all objects in the bucket.

        To specify a specific object, enter the object name.

        To specify a set of objects, enter Object name prefix*, *Object name suffix, or *.

    Actions

    • Choose Use a template.
    • Select Object Read-Only.

  7. Ensure all the configurations are correct and click Create.