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: no roles being returned for anonymous user #15585

Merged

Conversation

aspedrosa
Copy link
Contributor

SUMMARY

Since 1.2.0 an anonymous user is unable to see a public dashboard.
This is caused because:

  1. no roles are attached to an anonymous user
  2. on the bootstrap_user_data function, when the user is anonymous, the permissions fetching process is skipped.

This will lead to an empty user payload
empty_user_on_state
leading to an Unexpected error on the dashboard page.

My changes: since an anonymous user doesn't have roles associated, on the bootstrap_user_data function, I associate the public role to it, which then on this line respective permissions can be fetched.

BEFORE/AFTER

Before:
Screenshots present on the three issues descriptions

After:
Dashboards are displayed without login

TESTING INSTRUCTIONS

  1. Add the permission mentioned in this comment to the public role OR set PUBLIC_ROLE_LIKE = "Gamma"
  2. Create a dashboard if don't have any
  3. Copy the URL for the dashboard
  4. Logout or enter an anonymous browser session
  5. Enter in the dashboard's URL
  6. Check if it renders properly with no Unexpected error.

ADDITIONAL INFORMATION

@codecov
Copy link

codecov bot commented Jul 8, 2021

Codecov Report

Merging #15585 (9f20996) into master (86a59a2) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 9f20996 differs from pull request most recent head 244cad5. Consider uploading reports for the commit 244cad5 to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##           master   #15585   +/-   ##
=======================================
  Coverage   76.87%   76.87%           
=======================================
  Files         976      976           
  Lines       51292    51293    +1     
  Branches     6907     6907           
=======================================
+ Hits        39430    39431    +1     
  Misses      11643    11643           
  Partials      219      219           
Flag Coverage Δ
hive 81.28% <100.00%> (+<0.01%) ⬆️
mysql 81.54% <100.00%> (+<0.01%) ⬆️
postgres 81.57% <100.00%> (+<0.01%) ⬆️
python 81.94% <100.00%> (+<0.01%) ⬆️
sqlite 81.18% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
superset/views/utils.py 83.33% <100.00%> (+0.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 86a59a2...244cad5. Read the comment docs.

@aspedrosa
Copy link
Contributor Author

@suddjian

Copy link
Member

@suddjian suddjian left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

Copy link
Member

@geido geido left a comment

Choose a reason for hiding this comment

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

LGTM! It looks like unit tests require some attention. Thanks!

@aspedrosa
Copy link
Contributor Author

aspedrosa commented Jul 16, 2021

I have seen other commits on master also failing the test that failed on this PR. Maybe it is not related.
For example, the tests of the associated PR for this commit passed, however, the tests for the merge commit failed

@rusackas rusackas merged commit e5540b7 into apache:master Jul 27, 2021
opus-42 pushed a commit to opus-42/incubator-superset that referenced this pull request Nov 14, 2021
cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Dec 17, 2021
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.3.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/S 🚢 1.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants