feat(auth): when user is not logged in, failure to access a dashboard should redirect to login screen #30380
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SUMMARY
If a viewer is not logged in, or they are the public/anonymous user, and they click a link that takes them to a Superset dashboard that is not public, they are currently told "You don't have access" and sent to the list of dashboards, where they will see only public ones listed. This is often misleading: in most cases, the problem is not that they don't have access -- they just need to log in.
After the PR, such cases are routed to the login screen, and after a successful login the users are sent back to the dashboard they were trying to access.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
BEFORE
current_redirect.mp4
AFTER
redirect_new.mp4
note I've changed the error message since recording this
TESTING INSTRUCTIONS
Create a dashboard with restricted access, try to view it while not logged in.
ADDITIONAL INFORMATION
Implements this feature request: #22190
Replaces this stale PR: #23280
I have the DASHBOARD_RBAC flag enabled as well as the Public role in use. My code alterations are minimal so I don't think it will negatively affect deployments that differ from mine, but it would be good to have someone check.
I'm not sure how to write tests for this but am open to it if someone can advise.