From e86f6bbabcc85f7005b6af85aabdfcf93acc6e82 Mon Sep 17 00:00:00 2001 From: Lily Kuang Date: Tue, 8 Feb 2022 20:14:11 -0800 Subject: [PATCH] fix: check embedded feature flag in request loader (#18628) * check embedded feature flag in request loader * lint * type annotation Co-authored-by: David Aaron Suddjian --- superset/security/manager.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/superset/security/manager.py b/superset/security/manager.py index 5ca81b2a9546e..d9206dfe4d374 100644 --- a/superset/security/manager.py +++ b/superset/security/manager.py @@ -235,13 +235,17 @@ class SupersetSecurityManager( # pylint: disable=too-many-public-methods guest_user_cls = GuestUser def create_login_manager(self, app: Flask) -> LoginManager: + lm = super().create_login_manager(app) + lm.request_loader(self.request_loader) + return lm + + def request_loader(self, request: Request) -> Optional[User]: # pylint: disable=import-outside-toplevel from superset.extensions import feature_flag_manager - lm = super().create_login_manager(app) if feature_flag_manager.is_feature_enabled("EMBEDDED_SUPERSET"): - lm.request_loader(self.get_guest_user_from_request) - return lm + return self.get_guest_user_from_request(request) + return None def get_schema_perm( # pylint: disable=no-self-use self, database: Union["Database", str], schema: Optional[str] = None