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

feat(auth): when user is not logged in, failure to access a dashboard should redirect to login screen #30380

Merged
merged 3 commits into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,9 +792,16 @@
try:
dashboard.raise_for_access()
except SupersetSecurityException as ex:
# anonymous users should get the login screen, others should go to dashboard list
if g.user is None or g.user.is_anonymous:
redirect_url = f"{appbuilder.get_url_for_login}?next={request.url}"
sfirke marked this conversation as resolved.
Show resolved Hide resolved
warn_msg = "Users must be logged in to view this dashboard."

Check warning on line 798 in superset/views/core.py

View check run for this annotation

Codecov / codecov/patch

superset/views/core.py#L796-L798

Added lines #L796 - L798 were not covered by tests
else:
redirect_url = "/dashboard/list/"
warn_msg = utils.error_msg_from_exception(ex)

Check warning on line 801 in superset/views/core.py

View check run for this annotation

Codecov / codecov/patch

superset/views/core.py#L800-L801

Added lines #L800 - L801 were not covered by tests
return redirect_with_flash(
url="/dashboard/list/",
message=utils.error_msg_from_exception(ex),
url=redirect_url,
message=warn_msg,
category="danger",
)
add_extra_log_payload(
Expand Down
Loading