当前位置: 首页 > news >正文

AWS Redshift把老用户权限赋予新用户

问题描述:

Redshift内已经有了一个user A,不知道赋予了A什么权限,希望将所有权限都赋予User B。

分析过程 及 测试:

在此为大家提供如下github上两个script,是很有用的:

1. 这个脚本可以帮忙把一个user所拥有的所有的object找到:

https://github.com/awslabs/amazon-redshift-utils/blob/master/src/AdminViews/v_find_dropuser_objs.sql

2. 这个脚本可以把一个user或者group具有的所有的权限,并生成一个可以在drop user以前去掉所有权限的ddl query集合:

amazon-redshift-utils/src/AdminViews/v_generate_user_grant_revoke_ddl.sql at master · awslabs/amazon-redshift-utils · GitHub

通过上面第二个脚本为例,我们测试如下:

建议运行时将第一行CREATE OR REPLACE VIEW admin.v_generate_user_grant_revoke_ddl 改为了 public.v_generate_user_grant_revoke_ddl

dev=# select ddl from public.v_generate_user_grant_revoke_ddl where grantee='root1';ddl
-------------------------------------------------------------------------------------------GRANT ALL on public.t2 to root1;GRANT ALL on schema public to root1;GRANT ALL on schema dict to root1;ALTER DEFAULT PRIVILEGES for user root in schema public GRANT SELECT  on tables to root1;REVOKE ALL on public.t2 FROM root1;REVOKE ALL on schema public FROM root1;REVOKE ALL on schema dict FROM root1;ALTER DEFAULT PRIVILEGES for user root in schema public REVOKE ALL on tables FROM root1;
(8 rows)

这个脚本是用来查看Grantee(root1) 的全部privilege并进行revoke的。我们可以用这个脚本,将user A的权限寻找出来,并在ddl编辑中替换成B,这样可以直接运行这个view产生的ddl,给B赋予所有A的权限。


http://www.mrgr.cn/news/39895.html

相关文章:

  • 防止错误输入!Excel单元格限制输入内容的三种有效方式
  • Arweave的出块原理
  • 高通芯片手机查看空口消息工具:QCAT
  • SpringBoot2(Spring Boot 的Web开发 springMVC 请求处理 参数绑定 常用注解 数据传递 文件上传)
  • OPenWrt编译文件解读makefile
  • spring 实用小技巧
  • 【C++】set详解
  • 【PHP陪玩系统源码】游戏陪玩系统app,陪玩小程序优势
  • uniapp学习(003-1 vue3学习 Part.1)
  • 使用RestTemplate调用EMQX API查询MQTT客户端列表信息
  • 什么是reactor以及其三种版本
  • vxe-grid给单元格加上触发事件
  • 快速幂算法
  • 【新闻转载】Storm-0501:勒索软件攻击扩展到混合云环境
  • 【Ubuntu】PlantUML工具 | 安装 | 语法 | 使用工具画序列图
  • 未来前端发展方向:深度探索与技术前瞻
  • VS2022 Git功能的使用
  • 【数据驱动预测控制2】Willems基本引理
  • Ubuntu开机进入紧急模式处理
  • 数据中心解决方案