本文為您介紹MaxCompute專案中的許可權管理命令全集,包含使用者管理、角色管理、使用者或角色授權、許可權查看等命令。
角色管理
命令
create role <role_name> [privilegeproperties("type"="admin|resource")];
樣本
建立一個Worker資源類角色,命令樣本如下。
create role Worker;
建立一個sale_admin管理類角色,命令樣本如下。
create role sale_admin privilegeproperties("type"="admin");
list roles;
命令
drop role <role_name>;
樣本
drop role Worker;
使用者管理
命令
樣本
命令
樣本
命令
樣本
命令
樣本
命令
樣本
命令
remove user `RAM$<accout_id>:role/<RAM角色名稱>`;
樣本
remove user ALIYUN$5527xxxxxxxx5788;
list users;
角色授權
為角色授予專案的操作許可權
命令
ACL授權
grant Read|Write|List|CreateTable|CreateInstance|CreateFunction|CreateResource|All on project <project_name> to ROLE <role_name> [privilegeproperties("conditions" = "<conditions>", "expires"="<days>")];
通過ACL文法實現Policy授權
grant Read|Write|List|CreateTable|CreateInstance|CreateFunction|CreateResource|All on project <project_name> to ROLE <role_name> privilegeproperties("policy" = "true", "{allow}"="{true|false}"[, "conditions"= "<conditions>", "expires"="<days>"]);
樣本
--ACL授權。 grant CreateTable, CreateFunction, CreateInstance, List on project test_project_a to ROLE Worker; --Policy授權。 grant CreateTable, CreateFunction, CreateInstance, List on project test_project_a to ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
為角色授予表的操作許可權
命令
ACL授權
grant Describe|Select|Alter|Update|Drop|ShowHistory|All on table <table_name> [(<column_list>)] to ROLE <role_name> [privilegeproperties("conditions" = "<conditions>", "expires"="<days>")];
通過ACL文法實現Policy授權
grant Describe|Select|Alter|Update|Drop|ShowHistory|All on table <table_name> [(<column_list>)] to ROLE <role_name> privilegeproperties("policy" = "true", "{allow}"="{true|false}"[, "conditions"= "<conditions>", "expires"="<days>"]);
樣本
--ACL授權。 grant Describe, Select on table sale_detail to ROLE Worker; --Policy授權。 grant Describe, Select on table sale_detail to ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
為角色授予資源的操作許可權
命令
ACL授權
grant Read|Write|Delete|All on resource <resource_name> to ROLE <role_name> [privilegeproperties("conditions" = "<conditions>", "expires"="<days>")];
通過ACL文法實現Policy授權
grant Read|Write|Delete|All on resource <resource_name> to ROLE <role_name> privilegeproperties("policy" = "true", "{allow}"="{true|false}"[, "conditions"= "<conditions>", "expires"="<days>"]);
樣本
--ACL授權。 grant Read, Write on resource udtf.jar to ROLE Worker; --Policy授權。 grant Read, Write on resource udtf.jar to ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
為角色授予函數的操作許可權
命令
grant Read|Write|Delete|Execute|All on function <function_name> to ROLE <role_name> [privilegeproperties("conditions" = "<conditions>", "expires"="<days>")];
樣本
--ACL授權。 grant Read, Write on function udf_test to ROLE Worker; --Policy授權。 grant Read, Write on function udf_test to ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
為角色授予執行個體的操作許可權
命令
ACL授權
grant Read|Write|All on instance <instance_id> to ROLE <role_name> [privilegeproperties("conditions" = "<conditions>", "expires"="<days>")];
通過ACL文法實現Policy授權
grant Read|Write|All on instance <instance_id> to ROLE <role_name> privilegeproperties("policy" = "true", "{allow}"="{true|false}"[, "conditions"= "<conditions>", "expires"="<days>"]);
樣本
--ACL授權。 grant All on instance 202112300224**** to ROLE Worker; --Policy授權。 grant All on instance 202112300224**** to ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
撤銷為角色授予的專案操作許可權
命令
撤銷ACL授權
revoke Read|Write|List|CreateTable|CreateInstance|CreateFunction|CreateResource|All on project <project_name> from ROLE <role_name>;
撤銷Policy授權
revoke Read|Write|List|CreateTable|CreateInstance|CreateFunction|CreateResource|All on project <project_name> from ROLE <role_name> privilegeproperties("policy" = "true", "{allow}"="{true|false}");
樣本
--撤銷ACL授權。 revoke CreateTable, CreateFunction, CreateInstance, List on project test_project_a from ROLE Worker; --撤銷Policy授權。 revoke CreateTable, CreateFunction, CreateInstance, List on project test_project_a from ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
撤銷為角色授予的表操作許可權
命令
撤銷ACL授權
revoke Describe|Select|Alter|Update|Drop|ShowHistory|All on table <table_name> [(<column_list>)] from ROLE <role_name>;
撤銷Policy授權
revoke Describe|Select|Alter|Update|Drop|ShowHistory|All on table <table_name> [(<column_list>)] from ROLE <role_name> privilegeproperties("policy" = "true", "{allow}"="{true|false}");
樣本
--撤銷ACL授權。 revoke Describe, Select on table sale_detail to ROLE Worker; --撤銷Policy授權。 revoke Describe, Select on table sale_detail from ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
撤銷為角色授予的資源操作許可權
命令
撤銷ACL授權
revoke Read|Write|Delete|All on resource <resource_name> from ROLE <role_name>;
撤銷Policy授權
revoke Read|Write|Delete|All on resource <resource_name> from ROLE <role_name> privilegeproperties("policy" = "true", "{allow}"="{true|false}");
樣本
--撤銷ACL授權。 revoke Read, Write on resource udtf.jar from ROLE Worker; --撤銷Policy授權。 revoke Read, Write on resource udtf.jar from ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
撤銷為角色授予的函數操作許可權
命令
撤銷ACL授權
revoke Read|Write|Delete|Execute|All on function <function_name> from ROLE <role_name>;
撤銷Policy授權
revoke Read|Write|Delete|Execute|All on function <function_name> from ROLE <role_name> privilegeproperties("policy" = "true", "{allow}"="{true|false}");
樣本
--撤銷ACL授權。 revoke Read, Write on function udf_test from ROLE Worker; --撤銷Policy授權。 revoke Read, Write on function udf_test from ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
撤銷為角色授予的執行個體操作許可權
命令
revoke Read|Write|All on instance <instance_id> from ROLE <role_name> privilegeproperties("policy" = "true", "{allow}"="{true|false}");
樣本
--撤銷ACL授權。 revoke All on instance 202112300224**** from ROLE Worker; --撤銷Policy授權。 revoke All on instance 202112300224**** from ROLE Worker privilegeproperties("policy" = "true", "allow"="true");
命令
grant Download on {Table|Resource|Function|Instance} <object_name> to ROLE <role_name>;
樣本
grant download on table sale_detail to ROLE Worker;
命令
revoke Download on {Table|Resource|Function|Instance} <object_name> from ROLE <role_name>;
樣本
revoke download on table sale_detail from ROLE Worker;
命令
grant Label <number> on table <table_name> [(<column_list>)] to ROLE <role_name> [with exp <days>];
樣本
grant Label 4 on table sale_detail to ROLE Worker;
命令
revoke Label on table <table_name> [(<column_list>)] from ROLE <role_name>;
樣本
revoke Label on table sale_detail from ROLE Worker;
命令
grant <role_name> to <user_name>;
樣本
grant Worker to ALIYUN$Kate@aliyun.com; grant Worker to RAM$Bob@aliyun.com:Allen;
命令
revoke <role_name> from <user_name>;
樣本
revoke Worker from ALIYUN$Kate@aliyun.com; revoke Worker from RAM$Bob@aliyun.com:Allen;
使用者授權
為使用者授予專案的操作許可權
命令
grant Read|Write|List|CreateTable|CreateInstance|CreateFunction|CreateResource|All on project <project_name> to USER <user_name> [privilegeproperties("conditions" = "<conditions>",
樣本
grant CreateTable, CreateFunction, CreateInstance, List on project test_project_a to user RAM$Kate@aliyun.com:Lily;
為使用者授予表的操作許可權
命令
grant Describe|Select|Alter|Update|Drop|ShowHistory|All on table <table_name> [(<column_list>)] to USER <user_name> [privilegeproperties("conditions" = "<conditions>"
樣本
grant Describe, Select on table sale_detail to USER RAM$Bob@aliyun.com:Allen;
為使用者授予資源的操作許可權
命令
grant Read|Write|Delete|All on resource <resource_name> to USER <user_name> [privilegeproperties("conditions" = "<conditions>",
樣本
grant Read, Write on resource udtf.jar to USER RAM$Bob@aliyun.com:Alice;
為使用者授予函數的操作許可權
命令
grant Read|Write|Delete|Execute|All on function <function_name> to USER <user_name> [privilegeproperties("conditions" = "<conditions>"
樣本
grant Read, Write on function udf_test to USER RAM$Bob@aliyun.com:Tom;
為使用者授予執行個體的操作許可權
命令
grant Read|Write|All on instance <instance_id> to USER <user_name> [privilegeproperties("conditions" = "<conditions>"
樣本
grant All on instance 202112300224**** to USER RAM$Bob@aliyun.com:Tom;
撤銷為使用者授予的專案的操作許可權
命令
revoke Read|Write|List|CreateTable|CreateInstance|CreateFunction|CreateResource|All on project <project_name> from USER <user_name>;
樣本
revoke CreateTable, CreateFunction, CreateInstance, List on project test_project_a from user RAM$Kate@aliyun.com:Lily;
撤銷為使用者授予的表的操作許可權
命令
revoke Describe|Select|Alter|Update|Drop|ShowHistory|All on table <table_name> [(<column_list>)] from USER <user_name>;
樣本
revoke Describe, Select on table sale_detail from USER RAM$Bob@aliyun.com:Allen;
撤銷為使用者授予的資源的操作許可權
命令
revoke Read|Write|Delete|All on resource <resource_name> from USER <user_name>;
樣本
revoke Read, Write on resource udtf.jar from USER RAM$Bob@aliyun.com:Alice;
撤銷為使用者授予的函數的操作許可權
命令
revoke Read|Write|Delete|Execute|All on function <function_name> from USER <user_name>;
樣本
revoke Read, Write on function udf_test from USER RAM$Bob@aliyun.com:Tom;
撤銷為使用者授予的執行個體的操作許可權
命令
revoke Read|Write|All on instance <instance_id> from USER <user_name>;
樣本
revoke All on instance 202112300224**** from USER RAM$Bob@aliyun.com:Tom;
命令
樣本
--為角色Worker授權。 --ACL授權。 grant CreateTable, CreateFunction, CreateInstance, List on project test_project_a to ROLE Worker; --Policy授權。 grant CreateTable, CreateFunction, CreateInstance, List on project test_project_a to ROLE Worker privilegeproperties("policy" = "true", "allow"="true"); --將角色Worker賦予使用者。 grant Worker to RAM$Bob@aliyun.com:Allen; grant Worker to RAM$Bob@aliyun.com:Alice; grant Worker to RAM$Bob@aliyun.com:Tom;
命令
樣本
--為角色Worker撤銷授權。 --撤銷ACL授權。 revoke CreateTable, CreateFunction, CreateInstance, List on project test_project_a from ROLE Worker; --撤銷Policy授權。 revoke CreateTable, CreateFunction, CreateInstance, List on project test_project_a from ROLE Worker privilegeproperties("policy" = "true", "allow"="true"); --或 --收回賦予使用者的角色Worker。 revoke Worker from RAM$Bob@aliyun.com:Allen;
命令
grant Download on {Table|Resource|Function|Instance} <object_name> to USER <user_name>;
樣本
grant Download on table sale_detail to USER RAM$Bob@aliyun.com:Allen;
命令
revoke Download on {Table|Resource|Function|Instance} <object_name> from USER <user_name>;
樣本
revoke Download on table sale_detail from USER RAM$Bob@aliyun.com:Allen;
命令
樣本
--建立角色Worker。 create role Worker; --為角色Worker授權。 grant download on table sale_detail to ROLE Worker; --將角色Worker賦予使用者。 grant Worker to RAM$Bob@aliyun.com:Allen; grant Worker to RAM$Bob@aliyun.com:Alice; grant Worker to RAM$Bob@aliyun.com:Tom;
命令
樣本
-為角色Worker撤銷授權。 revoke download on table sale_detail from ROLE Worker; --或 --收回賦予使用者的角色Worker。 revoke Worker from RAM$Bob@aliyun.com:Allen;
命令
grant Label <number> on table <table_name> [(<column_list>)] to USER <user_name> [with exp <days>];
樣本
grant Label 4 on table sale_detail to USER RAM$Bob@aliyun.com:Allen;
命令
revoke Label on table <table_name> [(<column_list>)] from USER <user_name>;
樣本
revoke Label on table sale_detail from ROLE Worker;
命令
樣本
--建立角色Worker。 create role Worker; --為角色Worker授權。 grant Label 4 on table * to ROLE Worker; --將角色Worker賦予使用者。 grant Worker to RAM$Bob@aliyun.com:Allen; grant Worker to RAM$Bob@aliyun.com:Alice; grant Worker to RAM$Bob@aliyun.com:Tom;
命令
樣本
-為角色Worker撤銷授權。 revoke Label on table * from ROLE Worker; --或 --收回賦予使用者的角色Worker。 revoke Worker from RAM$Bob@aliyun.com:Allen;
命令
purge privs from user <user_name>;
樣本
purge privs from user RAM$Bob@aliyun.com:Allen;
查詢許可權資訊
查詢指定角色的許可權及綁定的使用者資訊
查詢指定角色的許可權及綁定的使用者資訊詳情請參見查詢指定角色的許可權及綁定的使用者資訊。
命令
describe role <role_name>;
樣本
describe role Worker;
查詢使用者的許可權資訊
show grants;
命令
show grants for <user_name>;
樣本
show grants for ALIYUN$Bob@aliyun.com; show grants for RAM$Bob@aliyun.com:Allen;
查詢對象的ACL授權資訊
查詢對象的ACL授權資訊詳情請參見查詢指定對象的ACL授權資訊。
命令
show acl for <object_name> [on type <object_type>];
樣本
show acl for test_project_a on type project;
查詢Label許可權資訊
show label grants;
命令
show label <level> grants;
樣本
show label 2 grants;
命令
show label grants for user <user_name>;
樣本
show label grants for user RAM$Bob@aliyun.com:Allen;
命令
show label <level> grants for user <user_name>;
樣本
show label 3 grants for user RAM$Bob@aliyun.com:Allen;
命令
show label grants on table <table_name>;
樣本
show label grants on table sale_detail;
命令
show label <level> grants on table <table_name>;
樣本
show label 4 grants on table sale_detail;
命令
show label [<label>] grants on table <table_name> for user <user_name>;
樣本
show label grants on table sale_detail for user RAM$Bob@aliyun.com:Allen;
命令
describe <table_name>;
樣本
describe sale_detail;
查詢Package授權資訊
命令
show acl for <project_name>.<package_name> on type package;
樣本
show acl for test_project_b.datashare on type package;
命令
show grants on <object_type> <object_name> privilegeproperties ("refobject"="true", "refproject"="<project_name>", "package"="<package _name>");
樣本
show grants on Table sale_detail privilegeproperties ("refobject"="true", "refproject"="test_project_a", "package"="datashare");
命令
show label grants on table <table_name> privilegeproperties ("refobject"="true", "refproject"="<project_name>", "package"="<package_name>");
樣本
show label grants on table sale_detail privilegeproperties ("refobject"="true", "refproject"="test_project_a", "package"="datashare");
查看專案空間安全配置資訊
專案空間資料保護
開啟或關閉專案空間資料保護機制
set ProjectProtection=true|false;
查看專案空間的安全配置
show SecurityConfiguration;
返回結果中有
ProjectProtection=true|false
,對應專案空間資料保護機制已開啟或關閉。
查看已添加的可信的專案空間
list trustedprojects;
LabelSecurity許可權控制策略
開啟或關閉LabelSecurity許可權控制策略
set LabelSecurity=true|false;
查看專案空間的安全配置
show SecurityConfiguration;
返回結果中有
LabelSecurity=true|false
,對應專案空間LabelSecurity許可權控制策略已開啟或關閉。
Download許可權控制功能
開啟或關閉Download許可權控制功能
setproject odps.security.enabledownloadprivilege=true|false;
查看專案空間屬性
setproject;
返回結果中有
odps.security.enabledownloadprivilege = true|false
,對應專案空間Download許可權控制功能已開啟或關閉。