如何根据另一个视图中的用户权限限制对 Apache Drill 视图中敏感列的访问?

How can I restrict access to sensitive columns in Apache Drill view based on user permissions in another view?

背景: 我让用户使用 Kerberos 身份验证连接到 Apache Drill 以从 Parquet 文件中读取,因此基本上是一个包含多个列的 table。该文件中的某些列已知是敏感的,只有某些用户可以看到它们。除了数据 table,Drill 还可以访问另一个 table,其中包含可以访问敏感数据的信息(那里有 2 列:userId、sensitiveDataAccess)。需要强调的是,用户可以看到数据中的所有行 table,但只有有权访问敏感数据的用户才能看到敏感列。

这可以通过模拟来实现。 https://drill.apache.org/docs/configuring-user-impersonation/

解决方案是创建一个视图,将数据 table 与来自安全性 table 的一行连接起来,其中包含有关登录用户访问敏感数据的信息,然后使用 table 中的条件=16=] 子句在用户无权访问敏感列时使敏感列无效。

SELECT
  hc.name,
  CASE WHEN sec.`sensitiveDataAccess`=TRUE THEN hc.`salary` ELSE null END AS salary, --example of a sensitive column
FROM dfs.`/data/headcount.parquet` hc
JOIN (SELECT * FROM dfs.`/data/security.parquet` WHERE userId=session_user) sec
ON sec.userId=session_user;

您可能需要在 Drill 中启用笛卡尔连接以使其工作或在两个 table 中添加一个带有零的虚拟列,然后将以下内容添加到连接条件中作为解决方法:

AND hc.JoinHack=sec.JoinHack