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

fix: Add user filtering to changed_by. Fixes #27986 #29287

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

marre
Copy link

@marre marre commented Jun 18, 2024

SUMMARY

The EXTRA_RELATED_QUERY_FILTERS option only affected the "modified by" field, this PR changes it to also apply to the "owner" field.

This option is currently used in a superset installation where a superset user should not be able to list other superset user names. Without this PR a superset user can list the names of other users in the "modified by" field.

Fixes #27986

Documentation of the EXTRA_RELATED_QUERY_FILTERS:

# Extra related query filters make it possible to limit which objects are shown
# in the UI. For examples, to only show "admin" or users starting with the letter "b" in
# the "Owners" dropdowns, you could add the following in your config:

Example superset_config.py with EXTRA_RELATED_QUERY_FILTERS configured to hide all users:

# Hide all users
def user_filter(query):
    from sqlalchemy.sql import false
    return query.filter(false())

EXTRA_RELATED_QUERY_FILTERS = {
    "user": user_filter,
}

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:
image

After:
image

TESTING INSTRUCTIONS

  1. Add the EXTRA_RELATED_QUERY_FILTERS above to your superset_config.py file
  2. Click on "charts" to get the list of all charts
  3. Click on the "owner" drop-down, only your name should be visible
  4. Click on the "modified-by" drop-down, only your name should be visible (before this patch all users were visible)

ADDITIONAL INFORMATION

  • Has associated issue: Showing list of all the users name to other users #27986
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@github-actions github-actions bot added the api Related to the REST API label Jun 18, 2024
@dosubot dosubot bot added the authentication:access-control Rlated to access control label Jun 18, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Congrats on making your first PR and thank you for contributing to Superset! 🎉 ❤️

We hope to see you in our Slack community too! Not signed up? Use our Slack App to self-register.

@marre
Copy link
Author

marre commented Jun 18, 2024

Adding a link to the PR that introduced this feature for "owner" and "group".
#22526

Copy link

codecov bot commented Jun 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.74%. Comparing base (76d897e) to head (bc29572).
Report is 448 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #29287       +/-   ##
===========================================
+ Coverage   60.48%   83.74%   +23.25%     
===========================================
  Files        1931      524     -1407     
  Lines       76236    37789    -38447     
  Branches     8568        0     -8568     
===========================================
- Hits        46114    31646    -14468     
+ Misses      28017     6143    -21874     
+ Partials     2105        0     -2105     
Flag Coverage Δ
hive 49.13% <100.00%> (-0.03%) ⬇️
javascript ?
mysql 77.00% <100.00%> (?)
postgres 77.08% <100.00%> (?)
presto 53.71% <100.00%> (-0.10%) ⬇️
python 83.74% <100.00%> (+20.25%) ⬆️
sqlite 76.56% <100.00%> (?)
unit 59.86% <100.00%> (+2.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@marre
Copy link
Author

marre commented Jun 19, 2024

@dpgaspar : I think I have corrected the formatting. Would be nice if you can start the workflows again.

@rusackas
Copy link
Member

CI running 🤞

@marre
Copy link
Author

marre commented Jun 25, 2024

@rusackas : Added missing newline to get ruff linter happy

@dpgaspar would love to get a new CI run...

@marre
Copy link
Author

marre commented Jul 7, 2024

Would love to get some feedback if this PR is considered for merging. Or if I can improve it in some way.

@rusackas rusackas requested review from nytai and geido July 8, 2024 18:14
@marre
Copy link
Author

marre commented Jul 13, 2024

Updated branch with master to resolve merge conflict

@marre
Copy link
Author

marre commented Jul 13, 2024

Updated the "summary" of this PR with a better description and added "testing instructions"

@rusackas
Copy link
Member

Running CI again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Related to the REST API authentication:access-control Rlated to access control size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Showing list of all the users name to other users
2 participants