一个简单的 UserCase,带你认识 openLooKeng 的行级权限控制

Hi,朋友。openLooKeng 近期带来了许多技术干货,前有安装部署,后有安全认证机制、Hash Join 的使用介绍等等,如果您正在使用 openLooKeng, 希望这些技术博客能够帮助到您。本期,社区小伙伴将用一个 User Case,简单介绍 openLooKeng 的行级权限控制。
openLooKeng 的行级权限控制
行级权限的作用
通过 Rowfilter 实现对表数据行级别的权限控制:指定特定用户只能访问授权过的行,隐藏未授权的行数据。
Use Case
源数据表:

配置 Rowfilter 策略:

查询效果:

Rowfilter 实现方式
回顾一下 openLooKeng 的 coordinator 接收到一个 SQL 的处理过程:终端用户通过 ODBC 或者 JDBC driver 将一个 SQL 语句发送到 coordinator,这时 SQL 是以文本的形式被接收的。coordinator 会解析 parse 和分析 analysis,然后生成 query plan。

openLooKeng analysis 过程分为两部分:StatementRewrite 和 StatementAnalyzer。这两部分中都有权限相关的检查。
考虑到:
Rangeradmin 侧仅存储鉴权策略,而鉴权逻辑在 openLooKeng 侧的 ranger-plugin 中完成。
Rowfilter 策略实际就是 where 条件子句。
所以,在 StatementRewrite 中将 Rowfilter 条件子句重写到 sql 中。
主要的代码修改涉及:
Ranger 侧:修改 openLooKeng 数据源的策略定义,增加行权限策略的配置界面。
openLooKeng 侧:增加一个新的 rewrite 类:RowFilteRewrite,将条件子句加到 sql 中。



以上便是本期小伙伴带来的分享。如果您也想在社区分享您的文章,欢迎联系 openLooKeng 小助手。
您可以 star 和 fork 代码仓,随时获取仓库更新动态。
欢迎访问 openLooKeng 官网 https://openlookeng.io
社区代码仓 https://gitee.com/openlookeng

本文为社区同学原创哦,转载请联系小助手
版权声明: 本文为 InfoQ 作者【openLooKeng】的原创文章。
原文链接:【http://xie.infoq.cn/article/2cc6e9b6f2e77d1b068613e4b】。
本文遵守【CC-BY 4.0】协议,转载请保留原文出处及本版权声明。
评论