Data Sharing Among Departments/Projects

An enterprise has data that needs to be shared among different departments or projects. To reduce the risks of mistaken deletion and tampering of shared data, the data can only be downloaded but not modified or deleted by users of other departments.

In this scenario, department A shares data in the bucket example-bucket to department B, allowing users of department B to download the data. This case describes how to leverage the least privilege principle to control access permissions for the shared data. Figure 1 shows the logical relationships among administrators, users, and buckets for data sharing between the two departments in this scenario.

Figure 1 Logical relationship

Solution and Process

In this scenario, the administrator of department A can use bucket policies to implement permission control, so that users of department B can only download but not modify or delete the shared data. Figure 2 illustrates the bucket policy configuration process.

Figure 2 Configuration process of permission control for data sharing

Prerequisites

Administrators and common users of departments A and B have been created on IAM. For details about how to create an IAM user, see Creating an IAM User.

The administrator of department A needs to perform operations such as creating buckets and configuring bucket policies. Therefore, when creating an administrator, the user group to which the administrator belongs must be granted at least the OBS Administrator permissions of OBS.

Procedure

  1. Create a bucket.

    1. Log in to the HUAWEI CLOUD console as the administrator of department A.
    2. On the console homepage, choose Service List > Storage > Object Storage Service to access OBS Console.
    3. On OBS Console, click Create Bucket in the upper right corner.
    4. Select a region, storage class, and bucket policy, and then enter the bucket name.

      To ensure data security, set Bucket Policy to Private and set other parameters as prompted.

    5. Click Create Now. The bucket is created.

  2. Authorize users with the upload permission.

    If the OBS policy for the user group to which users of department A belong is Tenant Administrator, OBS Administrator, or OBS OperateAccess, skip this step and go to Step 3. If the OBS policy is not configured or the policy is set to OBS Buckets Viewer, OBS ReadOnlyAccess, or Tenant Guest, the administrator of department A needs to perform the following steps to grant the upload permission to users of department A.
    1. On OBS Console, click the name of the bucket where the shared data is stored and the Summary page of the bucket is displayed.
    2. In the navigation pane on the left, choose Permissions > Bucket Policy.
    3. Click Create Bucket Policy.
    4. In the first row of the bucket policy template, click Create Custom Policy.
    5. Set the following parameters to grant users in department A the permissions to access the bucket (list objects) and upload objects.
      Table 1 Parameters for granting permissions to access buckets and upload objects

      Parameter

      Description

      Policy View

      Select Visual editor.

      Policy Name

      Custom

      Policy Content

      Effect

      Select Allow.

      Principal

      • Principal: Current account
      • Sub-user: Select the users of department A who are allowed to upload data.
      • User Policy: Include specified users.

      Resources

      • Resource: Select Current bucket and Object in bucket and then select All objects under Object in bucket.
      • Resource Policy: Include specified resources.

      Actions

      • Select ListBucket and PutObject.
      • Operation Strategy: Include selected actions.
    6. Click Next in the lower right corner.
    7. Click Create.

  3. Authorize users with the download permission.

    If the policy for the user group to which users of department B belong is Tenant Administrator, OBS Administrator, OBS OperateAccess, or Tenant Guest, skip this step and go to step 4. If the OBS policy is not configured or the policy is set to OBS Buckets Viewer or OBS ReadOnlyAccess, the administrator of department A needs to perform the following steps to grant the download permission to users of department B.
    1. On OBS Console, click the name of the bucket where the shared data is stored and the Overview page of the bucket is displayed.
    2. In the navigation pane on the left, choose Permissions > Bucket Policy.
    3. Click Create Bucket Policy.
    4. In the first row of the bucket policy template, click Create Custom Policy.
    5. Set the following parameters to grant users in department B the permission to download objects.
      Table 2 Parameters for authorizing the permission to download objects

      Parameter

      Description

      Policy View

      Select Visual editor.

      Policy Name

      Custom

      Policy Content

      Effect

      Select Allow.

      Principal

      • Principal: Current account
      • Sub-user: Select the users of department B who are allowed to download data.
      • User Policy: Include specified users.

      Resources

      • Resource: Select Current bucket and Object in bucket and then select All objects under Object in bucket.

        If you need to share only a folder or a set of objects in the bucket, select Specific objects under Object in bucket, and, under Resource path, enter the name of the folder (for example, example-folder/) or an object set with a wildcard character (for example, *.doc, indicating all objects whose name ends with .doc). You can add multiple object name prefixes.

      • Resource Policy: Include specified resources.

      Actions

      • Select ListBucket, GetObject, and GetObjectVersion.
      • Operation Strategy: Include selected actions.
    6. Click Next in the lower right corner.
    7. Click Create.

  4. Prevent users from modifying and deleting the shared data.

    1. On OBS Console, click the name of the bucket where the shared data is stored and the Overview page of the bucket is displayed.
    2. In the navigation pane on the left, choose Permissions > Bucket Policy.
    3. Click Create Bucket Policy.
    4. In the first row of the bucket policy template, click Create Custom Policy.
    5. Set the following parameters to prevent users in department B from writing or deleting the shared data.
      Table 3 Parameters for preventing users from writing or deleting data

      Parameter

      Description

      Policy View

      Visual editor

      Policy Name

      Custom

      Policy Content

      Effect

      Deny

      Principal

      • Principal: Current account
      • Sub-user: Select users of department B who are not allowed to write or delete data.
      • User Policy: Include specified users.

      Resources

      • Resource: Select Current bucket and Object in bucket and then select All objects under Object in bucket.

        If you need to prevent users from writing or deleting only a folder or a set of objects in the bucket, select Specific objects under Object in bucket, and, under Resource path, enter the name of the folder (for example, example-folder/) or an object set with a wildcard character (for example, *.doc, indicating all objects whose name ends with .doc). You can add multiple object name prefixes.

      • Resource Policy: Include specified resources.

      Actions

      • Select the following actions:
        • PutObject
        • PutObjectAcl
        • PutObjectVersionAcl
        • DeleteObject
        • DeleteObjectVersion
        • AbortMultipartUpload
      • Operation Strategy: Include selected actions.
    6. Click Next in the lower right corner.
    7. Click Create.

  5. Upload data.

    Users in department A can upload data through OBS Console, OBS Browser+, APIs, and SDKs. This section takes the operations on OBS Console as an example to describe how to upload data.
    1. Log in to OBS Console as a user of department A.
    2. In the bucket list, click the name of the bucket that stores the shared data.
    3. In the navigation pane on the left, click Objects and then Upload Object.
    4. In the displayed Upload Object dialog box, select the upload mode, storage class, and data to be uploaded.
    5. Click Upload.

      You can click Task Management in the lower part of the page to view the upload progress and result.

  6. Verify the permission.

    After the permission is configured, users of department B can verify the permissions using OBS Console, OBS Browser+, APIs, and SDKs. This section takes OBS Console as an example to present how to verify that users of department B can only read the shared data.
    1. Log in to OBS Console as an IAM user of department B.
    2. In the bucket list, click the name of the target bucket.
    3. In the left navigation pane, click Objects. The object list is displayed.
    4. Click Download in the row where a public data record is located.
      • If the download fails, the download permission fails to be granted. Check whether the user group permission configuration is correct.
      • If the download is successful, the download permission is granted successfully. Go to the next step.
    5. Click Upload Object, select a file, and click Upload.
      • If the upload is successful, the permission configuration for preventing write and deletion by users of other departments fails. Check whether the bucket policy is correctly configured.
      • If the upload fails, the permission configuration is successful. Go to the next step.
    6. Click Delete in the row where a public data record is located.
      • If the deletion is successful, the permission configuration for preventing write and deletion by users of other departments fails. Check whether the bucket policy is correctly configured.
      • If the deletion fails, the permission configuration is successful.