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

本文涉及的产品
云原生大数据计算服务 MaxCompute,5000CU*H 100GB 3个月
云原生大数据计算服务MaxCompute,500CU*H 100GB 3个月
简介: 【实验】阿里云大数据助理工程师认证(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的热门话题分析
本实验围绕社交用户发布的文章做了详尽的分析,通过分析能得到用户群体年龄分布,性别分布,地理位置分布,以及热门话题的热度。
SaaS 模式云数据仓库必修课
本课程由阿里云开发者社区和阿里云大数据团队共同出品,是SaaS模式云原生数据仓库领导者MaxCompute核心课程。本课程由阿里云资深产品和技术专家们从概念到方法,从场景到实践,体系化的将阿里巴巴飞天大数据平台10多年的经过验证的方法与实践深入浅出的讲给开发者们。帮助大数据开发者快速了解并掌握SaaS模式的云原生的数据仓库,助力开发者学习了解先进的技术栈,并能在实际业务中敏捷的进行大数据分析,赋能企业业务。 通过本课程可以了解SaaS模式云原生数据仓库领导者MaxCompute核心功能及典型适用场景,可应用MaxCompute实现数仓搭建,快速进行大数据分析。适合大数据工程师、大数据分析师 大量数据需要处理、存储和管理,需要搭建数据仓库?学它! 没有足够人员和经验来运维大数据平台,不想自建IDC买机器,需要免运维的大数据平台?会SQL就等于会大数据?学它! 想知道大数据用得对不对,想用更少的钱得到持续演进的数仓能力?获得极致弹性的计算资源和更好的性能,以及持续保护数据安全的生产环境?学它! 想要获得灵活的分析能力,快速洞察数据规律特征?想要兼得数据湖的灵活性与数据仓库的成长性?学它! 出品人:阿里云大数据产品及研发团队专家 产品 MaxCompute 官网 https://www.aliyun.com/product/odps 
目录
相关文章
|
4月前
|
大数据 Linux 网络安全
大数据开发工程师基本功修炼之史上最全Linux学习笔记(建议)
大数据开发工程师基本功修炼之史上最全Linux学习笔记(建议)
175 0
|
11月前
|
分布式计算 Hadoop 大数据
【大数据开发技术】实验05-HDFS目录与文件的创建删除与查询操作
【大数据开发技术】实验05-HDFS目录与文件的创建删除与查询操作
129 0
|
2月前
|
分布式计算 安全 大数据
HAS插件式Kerberos认证框架:构建安全可靠的大数据生态系统
在教育和科研领域,研究人员需要共享大量数据以促进合作。HAS框架可以提供一个安全的数据共享平台,确保数据的安全性和合规性。
|
1月前
|
SQL 开发框架 大数据
【数据挖掘】顺丰科技2022年秋招大数据挖掘与分析工程师笔试题
顺丰科技2022年秋招大数据挖掘与分析工程师笔试题解析,涵盖了多领域选择题和编程题,包括动态规划、数据库封锁协议、概率论、SQL、排序算法等知识点。
55 0
|
4月前
|
分布式计算 监控 大数据
《吊打面试官》- 大数据工程师50道中大厂面试真题保姆级详解
《吊打面试官》- 大数据工程师50道中大厂面试真题保姆级详解
80 1
《吊打面试官》- 大数据工程师50道中大厂面试真题保姆级详解
|
4月前
|
SQL 分布式计算 算法
程序员必备的面试技巧——大数据工程师面试必备技能
程序员必备的面试技巧——大数据工程师面试必备技能
94 0
|
4月前
|
Java 数据库连接 数据库
Java大数据开发工程师__Spring学习笔记(待更新)
Java大数据开发工程师__Spring学习笔记(待更新)
49 1
|
4月前
|
关系型数据库 MySQL 大数据
大数据开发工程师基本功修炼之Linux学习笔记(四)
大数据开发工程师基本功修炼之Linux学习笔记(四)
127 1
|
4月前
|
大数据 Linux 开发工具
大数据开发工程师基本功修炼之Linux学习笔记(三)
大数据开发工程师基本功修炼之Linux学习笔记(三)
99 0
|
4月前
|
大数据 Java Linux
大数据开发工程师基本功修炼之Linux学习笔记(二)
大数据开发工程师基本功修炼之Linux学习笔记(二)
106 0

热门文章

最新文章