-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
[SIP] API Row Level Security: get rls by username or roles via API (tested on Apache Superset 2.1.0) #25352
base: master
Are you sure you want to change the base?
Conversation
(cherry picked from commit d4362a3)
…ache#23196) (cherry picked from commit 196e3ea)
…created with the Dynamic Form (apache#23195) (cherry picked from commit 218de6e)
Co-authored-by: Beto Dealmeida <[email protected]> (cherry picked from commit a0ca0c0)
) (cherry picked from commit 89576f8)
(cherry picked from commit f0f27a4)
(cherry picked from commit d0c54cd)
(cherry picked from commit 9673838)
…apache#23190) (cherry picked from commit 7d4aee9)
(cherry picked from commit 79274eb)
Co-authored-by: Ville Brofeldt <[email protected]> (cherry picked from commit b479e93)
…ite permissions (apache#23237) (cherry picked from commit 473a69a)
) (cherry picked from commit b180319)
(cherry picked from commit 5a099e0)
(cherry picked from commit 1f3eb56)
…applied (apache#23238) Co-authored-by: Ville Brofeldt <[email protected]> (cherry picked from commit 42980a6)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR @frlm. I'm not sure if you are aware but we have the following RLS endpoints. Are they not sufficient for your use case? ![]() |
Hi Michael, "result: [
{
"changed_on_delta_humanized": "string",
"clause": "string",
"description": "string",
"filter_type": "regular",
"group_key": "string",
"id": "0",
"name": "string",
"roles": [
{
"id": "0",
"name": "string"
}
],
"tables": [
{
"id": 0,
"schema": "string",
"table_name": "string"
}
] we can observe that there is all the information present in the RLS table plus the associated roles but during the embedding requests I observed the following shortcomings:
{
"resources": [
{
"id": "string",
"type": "dashboard"
}
],
"rls": [
{
"clause": "string",
"dataset": 0
}
],
"user": {
"first_name": "string",
"last_name": "string",
"username": "string"
}
}
This leads to greater difficulty on the Client side in using the tool via API because it must understand and manage any updates on the Superset side on how the settings relating to Row Level Security are managed. |
In scenarios like this, the best approach is to contribute to the master version, to ensure the contribution will be available in subsequent releases, and wait for a minor version of your current release that includes the new feature. An alternative is to just implement this feature locally for your deployment but you'll need to support it when upgrading.
I'm pretty sure we can resolve these use cases by a combination of filters ( |
You are right, I should have released on the master branch. However, I only added two methods within the file /superset/security/api.py; there are no other changes. |
@@ -28,6 +29,1178 @@ under the License. | |||
- [1.4.2](#142-sat-mar-19-000806-2022-0200) | |||
- [1.4.1](#141) | |||
|
|||
### 2.1 (Thu Mar 16 21:13:05 2023 -0700) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use current master for any change/PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is merging into master now.
@frim this seems to have slid under the radar for quite some time. Sorry about that. If you want to rebase the PR, we'll see how it works in current Superset, and review it. Hopefully we can get this across the finish line, but in the meantime, I'll set this to Draft mode while it awaits rebase. Mark it as open for review when you think it's ready. Thanks! |
SUMMARY
I have created the following SIP to give the client-side possibility to generate an embedding request by retrieving the row level securities defined on the UI page:
Providing either the username of the user or the role already defined on Apache Superset, API returns the list of RLS to be provided to body of endpoint /api/v1/security/guest_token/:
Otherwise, the client making the request must know in advance the settings provided at the user interface level. The following endpoints generate output considering the filter type (Basic / Regular) and the presence or absence of the Group Key. Right now a user without providing an rls but only the default value [ ], can display all the data within the dashboard, in my case I needed to manage the display of the type of data with respect to the user requesting the embedding. The output of request will be list of dictionaries with "clause" and "dataset" as keys, e.g:
If the different rls filters associated with the requested user or role have the same group key, the filters associated with the same dataset will be merged using the OR condition, e.g:
Proposed Change
I created new two endpoints:
that retrieve users, roles, tables and rls from Metadata tables (using the SQLAlchemy package), convert all filters of type Base to Regular and aggregate the filters with respect to the defined group key value. Obviously considering only the row level securities enabled on that specific user or role.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
BEFORE: no endpoints to retrieve RLS configs made by Row Level security settings page
AFTER:
![image](https://private-user-images.githubusercontent.com/95374244/269379285-c6860cd1-219f-47b5-b36b-a990d4fd0d07.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NjM4NTQsIm5iZiI6MTczODk2MzU1NCwicGF0aCI6Ii85NTM3NDI0NC8yNjkzNzkyODUtYzY4NjBjZDEtMjE5Zi00N2I1LWIzNmItYTk5MGQ0ZmQwZDA3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDIxMjU1NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTFjYTkzMzBiZjE4MmVjNDMyZTMwNjZjZmM3MmFjYmE1NmJiODhkNDVlZTZhYmU1ZTkyMTNmMmUyNGU1Mzc5ZTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.KNi89MbALT2Ua3vngRdTqcP_lDnNNVjQnUh56HO088A)
TESTING INSTRUCTIONS
Create an user with a specific role and related RLS, check if endpoints return correct output.
ADDITIONAL INFORMATION