You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by sf...@apache.org on 2024/09/25 18:26:32 UTC

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

This is an automated email from the ASF dual-hosted git repository.

sfirke pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 69d5f766a8 feat(auth): when user is not logged in, failure to access a dashboard should redirect to login screen (#30380)
69d5f766a8 is described below

commit 69d5f766a89005529c197c2e5424a59ada7a8b68
Author: Sam Firke <sf...@users.noreply.github.com>
AuthorDate: Wed Sep 25 14:26:26 2024 -0400

    feat(auth): when user is not logged in, failure to access a dashboard should redirect to login screen (#30380)
---
 superset/views/core.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/superset/views/core.py b/superset/views/core.py
index 56221b646a..1a21934bf9 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -792,9 +792,16 @@ class Superset(BaseSupersetView):
         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}"
+                warn_msg = "Users must be logged in to view this dashboard."
+            else:
+                redirect_url = "/dashboard/list/"
+                warn_msg = utils.error_msg_from_exception(ex)
             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(