-
Notifications
You must be signed in to change notification settings - Fork 17.1k
fix(security_manager): custom auth_view issue #39098
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -259,6 +259,10 @@ class SupersetSecurityManager( # pylint: disable=too-many-public-methods | |
| SecurityManager | ||
| ): | ||
| userstatschartview = None | ||
| register_superset_auth_view = True | ||
| """Set to False in subclasses that provide their own auth view.""" | ||
| register_superset_registeruser_view = True | ||
| """Set to False in subclasses that provide their own register user view.""" | ||
| READ_ONLY_MODEL_VIEWS = {"Database", "DynamicPlugin"} | ||
|
|
||
| role_api = SupersetRoleApi | ||
|
|
@@ -3167,10 +3171,12 @@ def is_admin(self) -> bool: | |
| def register_views(self) -> None: | ||
| from superset.views.auth import SupersetAuthView, SupersetRegisterUserView | ||
|
|
||
| self.auth_view = self.appbuilder.add_view_no_menu(SupersetAuthView) | ||
| self.registeruser_view = self.appbuilder.add_view_no_menu( | ||
| SupersetRegisterUserView | ||
| ) | ||
| if self.register_superset_auth_view: | ||
| self.auth_view = self.appbuilder.add_view_no_menu(SupersetAuthView) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'm actually a bit confused why this is being added here instead of just setting this as the authview in superset's security manager. That would avoid needing extra properties on the security manager and would just follow the established FAB pattern.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not 100 % convinced this |
||
| if self.register_superset_registeruser_view: | ||
| self.registeruser_view = self.appbuilder.add_view_no_menu( | ||
| SupersetRegisterUserView | ||
| ) | ||
|
|
||
| # Apply rate limiting to auth view if enabled | ||
| # This needs to be done after the view is added, otherwise the blueprint | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conditional registration of SupersetAuthView is good, but the rate limiting code later assumes self.auth_view always exists. If a subclass sets register_superset_auth_view = False, this will cause an AttributeError at runtime. The fix checks for auth_view's existence safely.
Code suggestion
Code Review Run #ec7c4a
Should Bito avoid suggestions like this for future reviews? (Manage Rules)