All Products
Search
Document Center

Object Storage Service:Share data across departments based on bucket policies

Last Updated:May 23, 2024

This topic describes how to use bucket policies to securely share data across departments or project teams by allowing some users to only download data and preventing them from writing or deleting data in Object Storage Service (OSS).

Background information

In this example, Department A wants to store data in a bucket named example-bucket and allow users in Department B to download the shared data. This topic shows how to follow the principle of least privilege to control access to shared data. The following figure shows the expected permissions of the administrators and users in Department A and Department B to access the example-bucket bucket.

image

Authorization process

In this example, the administrator of Department A can use the following steps to configure bucket policies that grant different access permissions on the bucket.

Prerequisites

  • RAM users for the administrators and users in Department A and Department B are created within the Alibaba Cloud account of the enterprise.

    For more information, see Create a RAM user.

  • The UIDs of the RAM users are obtained. For more information about how to query UIDs, see View the information about a RAM user.

  • Appropriate permissions are granted to the RAM users.

    In this example, the administrator of Department A needs to create buckets and configure bucket policies. Therefore, the AliyunOSSFullAccess policy must be attached to the RAM user group of the administrator. For more information, see Grant permissions to a RAM user.

Step 1: Create a bucket

Perform the following steps to create a bucket in the China (Hangzhou) region as the administrator of Department A:

  1. Log on to the OSS console as the administrator of Department A.

  2. In the left-side navigation pane, click Buckets. On the Buckets page, click Create Bucket.

  3. In the Create Bucket panel, configure the parameters.

    In this example, the bucket is named example-bucket. For more information about how to configure parameters to create a bucket, see Create buckets.

  4. Click OK.

Step 2: Grant permissions to upload shared data

Perform the following steps as the administrator of Department A to allow users in Department A to upload data to example-bucket:

  1. Click the name of the bucket created in Step 1.

  2. In the left-side navigation tree, choose Permission Control > Bucket Policy.

  3. On the Add in GUI tab of the Bucket Policy tab, click Authorize.

  4. In the Authorize panel, configure the following parameters and retain the default settings for other parameters.

    Parameter

    Description

    Applied To

    Select Whole Bucket to apply the bucket policy to the whole bucket.

    Authorized User

    Select RAM User.

    From the RAM user drop-down list, select the RAM users to which you want to grant the permissions to upload data to the bucket. You can also enter a username or keyword in the search box to search for specific RAM users by fuzzy match.

    Authorized Operation

    Select Basic Settings and click Read/Write.

    This option indicates that authorized users can perform read and write operations on the bucket.

  5. Click OK.

    Users in Department A are granted permissions to upload data to the bucket.

Step 3: Grant permissions to download shared data and deny writes and deletion of shared data

Perform the following steps as the administrator of Department A to allow users in Department B to download shared data from example-bucket:

  1. Click the name of the bucket created in Step 1.

  2. In the left-side navigation tree, choose Permission Control > Bucket Policy.

  3. On the Add in GUI tab of the Bucket Policy tab, click Authorize.

  4. In the Authorize panel, configure the following parameters and retain the default settings for other parameters.

    Parameter

    Description

    Applied To

    Select Whole Bucket to apply the bucket policy to the whole bucket.

    Authorized User

    Select Other Accounts. Enter the UIDs of the RAM users that you want to allow to download shared data.

    Authorized Operation

    Select Basic Settings and click Read-only (including ListObject).

    This option indicates that authorized users can only view, list, and download data but cannot write or delete data stored in example-bucket.

  5. Click OK.

    Users in Department B are granted permissions to download data from the bucket. They are not allowed to write data to the bucket or delete data from the bucket.

Step 4: Upload data to the bucket

Perform the following steps to upload data to example-bucket as a user of Department A:

  1. Log on to the OSS console as a RAM user in Department A.

  2. Open the object upload page at https://oss.console.aliyun.com/bucket/hangzhou/example-bucket/object/upload.

  3. On the Upload page, configure parameters to upload data.

    Select Current Directory for Upload To. For more information about parameter settings in an upload, see Upload objects.

  4. On the Upload Tasks tab of the Task List panel, check the task progress. After the upload is complete, close the panel.

    The data is uploaded to example-bucket.

Step 5: Verify permissions

Perform the following steps in the OSS console to verify that users in Department B can download but cannot write or delete shared data:

  1. Log on to the OSS console as a RAM user in Department B.

  2. Open the Objects page at https://oss.console.aliyun.com/bucket/hangzhou/example-bucket/object.

  3. On the Objects page, perform the following permission checks:

    1. Verify download permissions of users in Department B on shared data.

      Find an object in the example-bucket bucket and choose more > Download in the Actions column.

      • If the object cannot be downloaded, the download permissions are incorrectly configured.

      • If the object is downloaded, the download permissions are correctly configured.

    2. Verify upload permissions of users in Department B on shared data.

      Follow Step 4 to upload data to example-bucket.

      • If the upload operation fails, the intended upload permissions are correctly configured.

      • If the upload operation is successful, the intended upload permissions are incorrectly configured.

    3. Verify deletion permissions of users in Department B on shared data.

      Find an object in the example-bucket bucket and choose more > Delete.

      • If the delete operation fails, the intended delete permissions are correctly configured.

      • If the delete operation is successful, the intended delete permissions are incorrectly configured.