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

Filtering data per user on DB table level (Customer or Tenant Support) #7887

Closed
durchgedreht opened this issue Jul 17, 2019 · 9 comments
Closed
Labels
enhancement:request Enhancement request submitted by anyone from the community inactive Inactive for >= 30 days

Comments

@durchgedreht
Copy link

Is your feature request related to a problem? Please describe.

Most enterprise data sets are divided by a major ID column that strictly groups data of customer accounts into silos that are . not matched in 99% of the use cases - let's call the column "account_id" for a simple example. User Alice is allowed to see data "WHERE account_id = 1", Bob is allowed to see data "WHERE account_id=2" and Chris can see "WHERE account_id in (2 ,3)"

This filter should be applied BEFORE any data hits dashboard or Slice logic. Ideally speaking one user should see only his data in the table - as if none else would use the system.

Describe the solution you'd like

It would be great to have a general mechanism to define a column filter that always matches a predefined user criteria. In the perfect implementation this would be a selection of the users metadata against a table column:
First go to" Sources/tables/Edit Table"
There will be a new tab "FILTERS"
Here you can select a column and a criteria the value of the column needs to match against. The criteria can be obtained from the user object in the easiest implementation. In the given example it would be:

Table: my_fact_table
Column: account_id
Criteria:
my_fact_table.account_id = user.account_id (direct single match)
OR
my_fact_table.account_id in user.account_ids (1:many match)

In some use cases even a combination of two of those columns would make sense (think about sellers and buyers and a deal incorporating a buyer_id and seller_id). But this might be the last 20%.

Describe alternatives you've considered

There's potentially some not as convenient work around possible with JINJA. The docs are suboptimal here and it is also very SqlLab focussed. It would be great to have some better documentation how to use JINJA in this use case and potentially even point out how to deal with the users metadata better (most users will likely also be using SSO and potentially get the control data from a different app using SSO/OAuth or even a REST call).

Additional context

The functionality does not describe a full tenant support, but the most basic and most central topic would be covered: Clean separation of data. This looks like be a basic ask of many users in the data world. Implementation effort should be minor considering templating can be used internally.

@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label #enhancement to this issue, with a confidence of 0.96. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@issue-label-bot issue-label-bot bot added the enhancement:request Enhancement request submitted by anyone from the community label Jul 17, 2019
@mistercrunch
Copy link
Member

mistercrunch commented Jul 18, 2019

There have been conversations about this, we call this feature "row level security", but haven't implemented it yet. This would require a solid SiP (Superset improvement proposal)

@durchgedreht
Copy link
Author

Hi,
nice to hear there has been at least some ideas floating around. Can you point me to the feature "row level security" as I can only find a closed issue from 2016?

@cbg-jahn
Copy link

cbg-jahn commented Aug 5, 2019

Re: row level security (RLS)

Dear Apache Derby community:

The RLS subject was discussed recently in H2 and HSQLDB forums. The excerpt is provided below.

[H2 database]

20190426 row level security
groups.google.com/forum/#!msg/h2-database/kn5E7B_70rQ/GkZ_dnACDAAJ

[HSQLDB]

20190704 SQL corruption, Filter clause
[user guide] HSQLDB 2.5.0, page 101,
row level security (RLS), using the Filter clause.
www.sf.net/p/hsqldb/discussion/73674/thread/fe3b588587

Sincerely,
Ray

[design draft]

HSQLDB 2.5.0, user guide, page 101,
fine grained access control,
Filter Where clause for RLS.

Would H2 become capable of RLS by adding (Where clause) to the Grant statement?

in syntax

Grant ... on Table client_po to role_merchant
Where ( client, USER() ) in (Select client, merchant from permission_table);

in semantics

Grant ... on Table client_po to role_merchant
Where ( client, USER() ) in permission_table( client, merchant );

The reasoning is provided below.

[business case]

We are looking for a terse solution to access control, with a differentiation metric based on the (assignment / association).

Each client, or (client, division), is assigned to a group of merchants. The organization table (client, merchant) ensues. Company adjusts the groups (reallocating merchants) upon business change. In database each client should be served / handled only by assigned / authorized merchants at the given time.

Two types of Grant syntax exist for access control.

  1. table based
    Grant ... on Table client_po to role_merchant;

In table based approach, all merchants are allowed access to all client POs in the entire table. No differentiation among merchants. This is not enough.

  1. row based
    Grant ... on Table client_po to role_merchant
    Where ( client, USER() ) in permission_table( client, merchant );

In row based approach, when the (Where ... in ...) predicate is supported in the Grant statement, the permission_table( client, merchant ) would control, ROW BY ROW, the access to the table of trading data. This RLS, based on differentiation metric of (client-merchant association), is what we need. This scenario of (client-merchant association) may be extended to financial industry, health care systems, insurance claims, etc., where agents are assigned / authorized to serve the designated institutional clients.

Alternative designs could achieve similar security results. But the Where clause in HSQLDB 2.5.0 appears to be a clever winner hands down. It is terse, versatile, easy on code maintenance, and very importantly, easy on association management (personnel reallocation) in database.

@PayneZx
Copy link

PayneZx commented Sep 11, 2019

@mistercrunch . I want to know if this feature is being developed.Beause I also need this feature.If this feature is being developed, when can it be online?

@axuew
Copy link
Contributor

axuew commented Oct 16, 2019

There have been conversations about this, we call this feature "row level security", but haven't implemented it yet. This would require a solid SiP (Superset improvement proposal)

Is it Available macros?At present, I control the data permission by such custom. I know it is not perfect, but it solves my current dilemma

image
image

@jackyq2015
Copy link

Can this be done though defining the data source? It will be safer and can be reused

@willbarrett
Copy link
Member

Currently this PR is in the works: #8699 - feel free to take a look and provide feedback.

@stale
Copy link

stale bot commented Jan 31, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement:request Enhancement request submitted by anyone from the community inactive Inactive for >= 30 days
Projects
None yet
Development

No branches or pull requests

7 participants