【实验】阿里云大数据助理工程师认证(ACA)- ACA认证配套实验-05-安全与权限基本操作(下)

简介: 【实验】阿里云大数据助理工程师认证(ACA)- ACA认证配套实验-05-安全与权限基本操作(下)

2.2 实验:角色管理与授权


提示:本章节所需操作均需使用阿里云主账号或者具有项目admin权限的用户进行实验,实验环境需在各阿里云主账号对应的项目中进行。


1、用户A新建一个角色 reader:

create role reader;

2、用户A赋予角色reader几张表的读权限:


grant describe, select on table dual to role reader;
grant describe, select on table t_test to role reader;


3、用户A查看角色的权限:


desc role reader;


4、用户A查看B用户拥有的权限:


show grants for ALIYUN$huiongshan@126.com;


5、用户A将角色reader赋予用户B:


grant reader to ALIYUN$huiongshan@126.com;


6、用户A查看B用户拥有的权限:


show grants for ALIYUN$huiongshan@126.com;


7、用户A赋予角色reader另外几张表的读权限:

grant describe, select on table t_tunnel to role reader;
grant describe, select on table t_tunnel_p to role reader;

8、用户A查看角色的权限和使用情况:


desc role reader;


9、用户A查看B用户拥有的权限:


show grants for ALIYUN$huiongshan@126.com;


10、用户A删除角色reader(会报错,删除失败):


drop role reader;


11、用户A移除用户B(会报错,移除失败):


remove user ALIYUN$huiongshan@126.com;


12、用户A查看角色的权限和使用情况:


desc role reader;


13、用户A从用户B收回角色:


revoke reader from ALIYUN$huiongshan@126.com;


14、用户A删除角色reader:


drop role reader;


15、用户A移除用户B:


remove user ALIYUN$huiongshan@126.com;


2.3 实验:鉴权模型查看与管理


提示:本章节所需操作均需使用阿里云主账号或者具有项目admin权限的用户进行实验,实验环境需在各阿里云主账号对应的项目中进行。


1、用户A查看当前项目的鉴权模型:

show SecurityConfiguration;

2、用户A赋予用户B建表的权限:


add user ALIYUN$huiongshan@126.com;
grant createtable on project Lab_class to user ALIYUN$huiongshan@126.com;


3、用户B建表:


create table Lab_class.t_test_sg (id int);
desc Lab_class.t_test_sg;
select count(*) from Lab_class.t_test_sg;


image.png

image.png

image.png


4、用户A修改鉴权模型,将ObjectCreatorHasAccessPermission改为false:

set ObjectCreatorHasAccessPermission=false;
show SecurityConfiguration;


5、用户B访问Lab_class.t_test_sg(报错,权限不足):


desc Lab_class.t_test_sg;
select count(*) from Lab_class.t_test_sg;


image.png

image.png


6、用户B删除Lab_class.t_test_sg(报错,权限不足):


drop table Lab_class.t_test_sg;


image.png


7、用户A修改鉴权模型,将ObjectCreatorHasAccessPermission改为true:

set ObjectCreatorHasAccessPermission=true;
show SecurityConfiguration;

8、用户B访问Lab_class.t_test_sg:


desc Lab_class.t_test_sg;
select count(*) from Lab_class.t_test_sg;


image.png

image.png


9、用户B删除Lab_class.t_test_sg:


drop table Lab_class.t_test_sg;


image.png


10、用户A收回用户B建表的权限:

revoke createtable on project Lab_class from user ALIYUN$huiongshan@126.com;
remove user ALIYUN$huiongshan@126.com;


2.4 实验:基于标签的安全控制


提示:本章节所需操作均需使用阿里云主账号或者具有项目admin权限的用户进行实验,实验环境需在各阿里云主账号对应的项目中进行。


1、用户A查看当前项目的鉴权模型:

show SecurityConfiguration;


2、如果LabelSecurity的值为false,则需要将它设置成true:


set LabelSecurity=true;


3、增加用户B到当前项目Lab_class,并设置安全许可标签:


(默认安全标签为0,我们将用户B(ALIYUN$huiongshan@126.com) 安全许可标签设置为3)
add user ALIYUN$huiongshan@126.com;
set label 3 to user ALIYUN$huiongshan@126.com;
grant select,describe on table t_tunnel to user ALIYUN$huiongshan@126.com;


4、用户B此时可以访问Lab_class.t_tunnel:


select * from Lab_class.t_tunnel;


image.png


5、用户A将t_tunnel的id敏感等级提高成4:


set label 4 to table t_tunnel(id);


image.png


6、用户B此时因安全等级低,无法访问敏感等级高的数据Lab_class.t_tunnel:


select * from Lab_class.t_tunnel;


image.png


7、用户A将t_tunnel中的id字段的敏感度调整到3:


set label 3 to table t_tunnel(id);


8、用户B此时可以访问Lab_class.t_tunnel中敏感级别不大于3的列id:


select id from Lab_class.t_tunnel;


image.png

9、用户A可以设置对低权限用户B进行临时授权可以访问高敏感级别的表t_tunnel_p:


set label 3 to user ALIYUN$huiongshan@126.com;
grant select,describe on table t_tunnel_p to user ALIYUN$huiongshan@126.com;
set label 5 to table t_tunnel_p(name);
set label 4 to table t_tunnel_p (id);
grant label 4 on table t_tunnel_p to user ALIYUN$huiongshan@126.com with exp 1;


10、用户B此时可以访问Lab_class.t_tunnel_p中敏感级别不大于4的所有列:


select id from Lab_class.t_tunnel_p;
select name from Lab_class.t_tunnel_p;


image.png

image.png


11、用户A查看当前有权限访问t_tunnel_p的表的用户列表:


show label grants on table t_tunnel_p;


12、用户A查看用户B有权限访问的所有的表的列表:


show grants for ALIYUN$huiongshan@126.com;


13、用户A收回用户B权限,并从项目中移除用户B,并复原项目的鉴权模型:

revoke describe,select on table t_tunnel from user ALIYUN$huiongshan@126.com;
revoke describe,select on table t_tunnel_p from user ALIYUN$huiongshan@126.com;
remove user ALIYUN$huiongshan@126.com;
set LabelSecurity=false;
show SecurityConfiguration;


2.5 实验:跨项目空间的资源分享


提示:本章节所需操作均需使用阿里云主账号或者具有项目admin权限的用户进行实验,实验环境需在各阿里云主账号对应的项目中进行。


1、用户A创建package,并将表t_tunnel以及表t_tunnel_p的访问权限添加到该package:

create package pk_tunnel_read;
add table t_tunnel to package pk_tunnel_read with privileges select;
add table t_tunnel_p to package pk_tunnel_read with privileges describe;

2、用户A将pk_tunnel_read赋给用户B所在的项目Star_research:


allow project Star_research to install package pk_tunnel_read;


3、用户B查看所在项目空间可用的package:


show packages;


image.png

4、用户B安装pk_tunnel_read:


install package Lab_class.pk_tunnel_read;
show packages;
desc package Lab_class.pk_tunnel_read;


image.png

image.png

image.png


5、用户B访问package中包含的资源:

select * from Lab_class.t_tunnel;
desc Lab_class.t_tunnel_p;


image.png

image.png


6、用户B卸载package:


uninstall package Lab_class.pk_tunnel_read;


image.png

7、用户A删除package:


drop package pk_tunnel_read;


2.6 实验:项目空间保护


提示:本章节所需操作均需使用阿里云主账号或者具有项目admin权限的用户进行实验,实验环境需在各阿里云主账号对应的项目中进行。


1、用户A查看当前项目的鉴权模型,确认目前的ProjectProtection处于false状态:


show SecurityConfiguration;


2、增加用户B到当前项目Lab_class,并赋予表t_tunnel的读写权限:


add user ALIYUN$huiongshan@126.com;
grant all on table t_tunnel to user ALIYUN$huiongshan@126.com;
grant select on table dual to user ALIYUN$huiongshan@126.com;


3、用户B操作表t_tunnel:可以读取记录,或者插入数据


select * from Lab_class.t_tunnel;
insert into table Lab_class.t_tunnel select  '1' from Lab_class.dual;


image.png

image.png


4、用户B甚至可以把表中的数据搬到本地的项目中来:


create table iris as select * from Lab_class.t_tunnel;


image.png


5、用户A为了防止数据流出,打开项目保护选项:ProjectProtection:


set ProjectProtection=true;


6、用户B对t_tunnel的操作都被禁止,需要联系Lab_class的owner:

select * from Lab_class.t_tunnel;
insert into table Lab_class.t_tunnel select  '-2' from Lab_class.t_tunnel;
create table iris_again as select * from Lab_class.t_tunnel;

image.png

image.png

image.png


7、用户A为用户B设置例外:

set ProjectProtection=true with exception c:\pf_try;
其中,pf_try为一个授权策略文件(ANSI/ANSII格式),内容如下:
{
“Version”: “1”,
“Statement”:[{
"Effect":"Allow",
"Principal":"ALIYUN$huiongshan@126.com",
"Action":["odps:Select"],
"Resource":["acs:odps:*:projects/Lab_class/tables/t_tunnel"],
"Condition":{
    "StringEquals": {
        "odps:TaskType":"SQL"
    } }

}]

}

8、用户B可以对表Lab_class.t_tunnel进行正常操作:

select * from Lab_class.t_tunnel;
create table iris_again as select * from Lab_class.t_tunnel;

image.png

image.png

9、用户A设置无例外项目保护:


set ProjectProtection=true;


第 3 章:实验总结


3.1 实验总结


通过本次实验,了解MaxCompute的用户授权、角色管理、鉴权模型、基于标签的安全控制、项目空间资源分享、项目空间保护等配置是如何实现,熟练掌握各种权限配置的方法,在后续的工作学习中,通过已学的配置方法,可较为方便的实现资源共享。

相关实践学习
基于MaxCompute的热门话题分析
Apsara Clouder大数据专项技能认证配套课程:基于MaxCompute的热门话题分析
目录
相关文章
|
8月前
|
存储 分布式计算 大数据
【赵渝强老师】阿里云大数据存储计算服务:MaxCompute
阿里云MaxCompute是快速、全托管的TB/PB级数据仓库解决方案,提供海量数据存储与计算服务。支持多种计算模型,适用于大规模离线数据分析,具备高安全性、低成本、易用性强等特点,助力企业高效处理大数据。
409 0
|
8月前
|
数据采集 人工智能 大数据
10倍处理效率提升!阿里云大数据AI平台发布智能驾驶数据预处理解决方案
阿里云大数据AI平台推出智能驾驶数据预处理解决方案,助力车企构建高效稳定的数据处理流程。相比自建方案,数据包处理效率提升10倍以上,推理任务提速超1倍,产能翻番,显著提高自动驾驶模型产出效率。该方案已服务80%以上中国车企,支持多模态数据处理与百万级任务调度,全面赋能智驾技术落地。
1183 0
|
6月前
|
人工智能 分布式计算 DataWorks
阿里云大数据AI产品月刊-2025年8月
阿里云大数据& AI 产品技术月刊【2025年 8 月】,涵盖 8 月技术速递、产品和功能发布、市场和客户应用实践等内容,帮助您快速了解阿里云大数据& AI 方面最新动态。
497 2
|
6月前
|
存储 分布式计算 资源调度
【赵渝强老师】阿里云大数据MaxCompute的体系架构
阿里云MaxCompute是快速、全托管的EB级数据仓库解决方案,适用于离线计算场景。它由计算与存储层、逻辑层、接入层和客户端四部分组成,支持多种计算任务的统一调度与管理。
574 1
|
8月前
|
人工智能 分布式计算 DataWorks
多模态数据处理新趋势:阿里云ODPS技术栈深度解析与未来展望
阿里云ODPS技术栈通过MaxCompute、Object Table与MaxFrame等核心组件,实现了多模态数据的高效处理与智能分析。该架构支持结构化与非结构化数据的统一管理,并深度融合AI能力,显著降低了分布式计算门槛,推动企业数字化转型。未来,其在智慧城市、数字医疗、智能制造等领域具有广泛应用前景。
718 6
多模态数据处理新趋势:阿里云ODPS技术栈深度解析与未来展望
|
存储 机器学习/深度学习 人工智能
阿里云ODPS:在AI浪潮之巅,铸就下一代智能数据根基
在智能爆炸时代,ODPS正从传统数据平台进化为“AI操作系统”。面对千亿参数模型与实时决策挑战,ODPS通过流批一体架构、多模态处理、智能资源调度等技术创新,大幅提升效率与智能化水平。从自动驾驶到医疗联合建模,从数字孪生到低代码AI开发,ODPS正重塑企业数据生产力,助力全球客户在算力洪流中抢占先机。
357 0