trinodb / trino

Official repository of Trino, the distributed SQL query engine for big data, formerly known as PrestoSQL (https://trino.io)
https://trino.io
Apache License 2.0
10.45k stars 3.01k forks source link

Pluggable AST(abstract syntax tree) rewrite to support 3rd party authorisation use cases #345

Open raviann opened 5 years ago

raviann commented 5 years ago

Terms AST - abstract syntax tree

Description Today one can provide custom authorisation by implementing io.prestosql.spi.security.SystemAccessControl in the plugin form. SystemAccessControl does support allow/deny kind of use-cases, which does not suffice for filter-masking and other use cases being required by 3rd party authorisation plugins

To support them, it would require AST rewrite, and today it is not pluggable either. We should make AST rewrite pluggable i.e io.prestosql.sql.rewrite.StatementRewrite.Rewrite to support the use-cases mentioned below

Use-cases

  1. Support for filter, masking and decryption of columns

  1. Logging of input query and the modified AST (in sql form) for audit purpose
martint commented 5 years ago

This falls under the umbrella of https://github.com/prestosql/presto/issues/18. Our plan is not to expose connectors to the AST, but to allow them to supply additional filters or projections base on authorization. There are multiple reasons why exposing the ASI to connectors is problematic: