Download permission control

Updated at:

MaxCompute supports Download access control to manage how roles and users use Tunnel to download tables and instances. This feature improves project data security and prevents data breaches. This topic describes the supported Download authorization commands and provides examples.

Background information

In a MaxCompute project, you can download tables and instances using Tunnel. However, download operations pose a security risk and can lead to data breaches. Therefore, you must restrict the permissions for these operations.

After you create a MaxCompute project, the Download access control feature is disabled by default. This means all users and roles in the project have Download permissions for all tables and instances. The project owner or a user with the Super_Administrator role can run the setproject odps.security.enabledownloadprivilege=true|false; command at the project level to enable or disable this feature.

Download access control applies to the following scenarios.

Scenario

Description

Authorizer

Authorization entry point

Grant permissions to a user

Grant a user the permission to download data from specified tables or instances.

For more information, see the Supported Authorizers column in Permission list.

Grant permissions to users based on a role

Grant a role the permission to download data from specified tables or instances. Then, attach the role to multiple users. The users inherit the permissions of the role.

Prerequisites

Before you use the Download access control feature, confirm that you have the following information:

  • The grantee's account name or role name. The user or role must be added to the MaxCompute project. The account formats are as follows: An Alibaba Cloud account is in the format ALIYUN$<account_name>, a RAM user account is in the format RAM$[<account_name>:]<RAM user name> , and a RAM role is in the format RAM$<account_name>:role/<RAM role name>.

    You can run the list users; or list roles; command in the MaxCompute client to retrieve account or role names.

    To add a user or role, see User planning and management or Role planning.

  • The type and name of the object to which you want to grant permissions.

    You can execute the show tables;, list resources;, list functions;, or show instances; command in the MaxCompute client to obtain the names of tables, views, and instances.

Limits

The following limits apply to the Download access control feature:

  • You can grant permissions only on existing objects and to existing grantees.

  • You can grant the Download permission on a specific object to a user. You cannot use a wildcard character to grant permissions to a user. To use a wildcard character, grant the permission to a role.

Notes

Note the following items when you use the Download access control feature:

  • If you delete an object, MaxCompute automatically revokes all Download authorizations associated with that object.

  • When a user is removed, their permissions are retained. If the user is added back to the project later, their previous permissions are automatically restored. To permanently clear a user's permissions, see Clear residual permissions of a removed user.

Command format

The commands for Download access control have the following format:

  • Grant Download permission

    grant Download on <object_type> <object_name> to <subject_type> <subject_name>;
  • Revoke Download permission

    revoke Download on <object_type> <object_name> from <subject_type> <subject_name>;

The following table describes the parameters.

Parameter Name

Required

Description

object_type

Yes

Specifies the type of the object. You can specify only one object per authorization.

Valid values:

  • Table: a table

  • Instance: an instance

object_name

Yes

Specifies the name of the object. You can obtain the name as follows:

  • Table name: You can use the MaxCompute client to execute the show tables; command to obtain the table or view name.

  • Instance name: You can execute the show instances; command in the MaxCompute client to obtain the instance ID.

When you grant permissions to a role, you can use an asterisk (*) as a wildcard character for the object name. For example, table taobao* indicates all tables whose names start with taobao.

subject_type

Yes

Specifies the type of the grantee.

  • USER: an Alibaba Cloud account or a RAM user

  • ROLE: role

subject_name

Yes

Specifies the name of the user account or role. You can specify only one user or role per authorization.

You can use the MaxCompute client to execute the list users; or list roles; command to obtain user account or role names.

Examples of Download access control

Assume that username@example.com is the owner of the test_project_a project, and Allen, Tom, and Alice are RAM users under the Alibaba Cloud account username@example.com. The Download access control feature is enabled for the test_project_a project. The following examples show authorization operations that are performed in the MaxCompute client:

  • Example 1: Grant the Download permission to a user

    Add the user Allen to the test_project_a project and grant the user permission to download data from the sale_detail table. The following sample commands show how to do this.

    -- Bob enters the test_project_a project.
    use test_project_a; 
    -- Add the user Allen as a project member.
    add user RAM$username@example.com:Allen;
    -- Allow the user Allen to download data from the sale_detail table in the test_project_a project.
    grant Download on table sale_detail to USER RAM$username@example.com:Allen;
    -- View the authorization result for the user Allen.
    show grants for RAM$username@example.com:Allen; 
    -- The following authorization result is returned. It indicates that the user Allen has the Download permission.
    Authorization Type: ACL
    [user/RAM$username@example.com:Allen]
    A       projects/test_project_a/tables/sale_detail: Download
  • Example 2: Revoke the Download authorization from a user

    Based on Example 1, revoke the authorization from the user Allen.

    -- Bob enters the test_project_a project.
    use test_project_a; 
    -- Revoke the authorization for the user Allen.
    revoke Download on table sale_detail from USER RAM$username@example.com:Allen;
    -- View the result for the user Allen after the authorization is revoked. The permission list does not contain Download information.
    show grants for RAM$username@example.com:Allen;  
  • Example 3: Grant the Download permission to multiple users based on a role

    Grant Alice and Tom permission to download data from tables whose names start with tb_ in the test_project_a project. The following sample commands show how to do this.

    -- Bob enters the test_project_a project.
    use test_project_a; 
    -- Add the users Alice and Tom as project members.
    add user RAM$username@example.com:Alice;
    add user RAM$username@example.com:Tom;
    -- Create the Worker role.
    create role Worker; 
    -- Assign the Worker role to the users.
    grant Worker TO RAM$username@example.com:Alice; 
    grant Worker TO RAM$username@example.com:Tom; 
    -- Allow the Worker role to download data from tables that start with tb_ in the test_project_a project.
    grant Download on table tb_* to ROLE Worker;
    -- View the authorization result for the user Alice.
    describe role Worker;
    -- The following authorization result is returned. A indicates that the Download operation is allowed.
    Authorization Type: Policy
    [role/worker]
    A       projects/test_project_a/tables/tb_*: Download
  • Example 4: Revoke the role-based Download permission from multiple users

    Based on Example 3, revoke the authorization from Alice and Tom.

    -- Bob enters the test_project_a project.
    use test_project_a; 
    -- Revoke the Worker role from the users Alice and Tom.
    revoke Worker from RAM$username@example.com:Alice;
    revoke Worker from RAM$username@example.com:Tom;
    -- View the result for the user Alice after the authorization is revoked. The permission list does not contain Download information.
    show grants for RAM$username@example.com:Alice; 

Next steps

After you understand how Download authorization works, you can perform the following authorization operations as needed: