Skip to content

Instantly share code, notes, and snippets.

@d9k
Created January 13, 2022 07:44
Show Gist options
  • Select an option

  • Save d9k/a638071ce7146ef01c27779a51d96f2b to your computer and use it in GitHub Desktop.

Select an option

Save d9k/a638071ce7146ef01c27779a51d96f2b to your computer and use it in GitHub Desktop.
Superset welcome page redirect
import logging
import pprint
from flask import Flask, redirect
from flask_appbuilder import expose, IndexView
from superset.typing import FlaskResponse
logger = logging.getLogger()
logger.warn("Loading config override for Uniweb");
WELCOME_PAGE_REDIRECT_ADMIN="/superset/dashboard/1/"
WELCOME_PAGE_REDIRECT_DEFAULT="/dashboard/list/"
WELCOME_PAGE_REDIRECT_BY_ROLE={
'Test': '/superset/dashboard/2/',
}
# Change welcome page
# https://stackoverflow.com/a/69930056/1760643
class SupersetDashboardIndexView(IndexView):
@expose("/")
def index(self) -> FlaskResponse:
from superset.views.base import is_user_admin, get_user_roles
user_roles = get_user_roles()
logger.warn('__DEBUG__ user roles: ' + pprint.pformat(user_roles))
if is_user_admin():
return redirect(WELCOME_PAGE_REDIRECT_ADMIN)
else:
for role in user_roles:
role_name = role.name
if role_name in WELCOME_PAGE_REDIRECT_BY_ROLE:
return redirect(WELCOME_PAGE_REDIRECT_BY_ROLE[role_name])
return redirect(WELCOME_PAGE_REDIRECT_DEFAULT)
FAB_INDEX_VIEW = f"{SupersetDashboardIndexView.__module__}.{SupersetDashboardIndexView.__name__}"
@joshfria
Copy link

Does this still work in version 5? I'm hesitant to upgrade because we need this.

@user1500177
Copy link

Hi community
is there a method to do this in superset version 5 and the latest version 6 ?

@floriandeutsch89
Copy link

floriandeutsch89 commented Jan 6, 2026

Hi community is there a method to do this in superset version 5 and the latest version 6 ?

See here. A bit different but still doable:
apache/superset#34594 (reply in thread)
apache/superset#34422 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment