Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple filters and masks from access control #11654

Conversation

ksobolew
Copy link
Contributor

Description

Is this change a fix, improvement, new feature, refactoring, or other?

It's an improvement to the SPI between the engine and the access control interfaces.

Is this a change to the core query engine, a connector, client library, or the SPI interfaces? (be specific)

SPI interfaces

How would you describe this change to a non-technical end user or system administrator?

The engine is perfectly capable of processing multiple row filter and column mask expressions, given that it supports running multiple system access controls and each of them can provide an expression. See: io.trino.security.AccessControlManager#getColumnMasks and io.trino.security.AccessControlManager#getRowFilters. So inability to provide more than one expression per access control looks like an artificial restriction. Case in point: the file-based access control, which is also already capable of providing multiple expressions for both row filters and column masks (it just picked the first one and discarded the rest).

Documentation

(x) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.

Release notes

(x) No release notes entries required. (I guess)
( ) Release notes entries required with the following suggested text:

# Section
* Fix some things. ({issue}`issuenumber`)

Copy link
Member

@gaurav8297 gaurav8297 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good!

Copy link
Member

@kokosing kokosing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me this does not change anything (I mean it is safe change) as we now allow multiple row filters and column masks. Now it is more explicit.

Anyway, I would like to hear @martint opinion too.

@martint
Copy link
Member

martint commented Mar 25, 2022

A couple of comments:

  • I'd like to understand the use case for this change. It's not clear to me why there would ever be more than one mask applied to a column for a given user.
  • Overall, the change is ok, but we adjust it to avoid breaking backward compatibility of the SPIs if possible (Introduce new APIs that delegate to the old ones, mark the old ones as deprecated)

@kokosing
Copy link
Member

In regards to SPI, please see #11667

I'd like to understand the use case for this change. It's not clear to me why there would ever be more than one mask applied to a column for a given user.

There are authorization systems that allows to configure row filters and column masking on schema as well as on table. So there is a case where it is set on both entities and so multiple filters or masks are returned.

@ksobolew ksobolew force-pushed the kudi/allow-multiple-filters-and-masks-from-access-control branch from 0320401 to 151164e Compare March 31, 2022 11:41
@ksobolew
Copy link
Contributor Author

I modified the commits to add new methods and deprecated the old ones instead of replacing.

@ksobolew ksobolew force-pushed the kudi/allow-multiple-filters-and-masks-from-access-control branch 2 times, most recently from 85742c4 to 3184de1 Compare March 31, 2022 14:14
ksobolew added 3 commits April 1, 2022 10:59
Can just collect to array directly.
The engine is perfectly capable of processing multiple row filter and
column mask expressions, given that it supports running multiple system
access controls and each of them can provide an expression. See:
`io.trino.security.AccessControlManager#getColumnMasks` and
`io.trino.security.AccessControlManager#getRowFilters`. So inability to
provide more than one expression per access control looks like an
artificial restriction. Case in point: the file-based access control,
which is also already capable of providing multiple expressions for both
row filters and column masks (it just picked the first one and discarded
the rest).
Now that the `SystemAccessControl` can provide multiple filtering and
masking expressions, there's no reason for the `ConnectorAccessControl`
not to follow suit.
@ksobolew ksobolew force-pushed the kudi/allow-multiple-filters-and-masks-from-access-control branch from 3184de1 to a63e04b Compare April 1, 2022 09:00
@kokosing kokosing merged commit 827de57 into trinodb:master Apr 3, 2022
@github-actions github-actions bot added this to the 376 milestone Apr 3, 2022
@ksobolew ksobolew deleted the kudi/allow-multiple-filters-and-masks-from-access-control branch April 4, 2022 13:23
*/
default List<ViewExpression> getRowFilters(ConnectorSecurityContext context, SchemaTableName tableName)
{
return emptyList();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new method should delegate to the old method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. As I was removing them I realized the same, not sure how it happened

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants