jayvenn21 commented on code in PR #37773:
URL: https://github.com/apache/superset/pull/37773#discussion_r2782657471


##########
superset/security/manager.py:
##########
@@ -3022,6 +3022,24 @@ def register_views(self) -> None:
             ) in ["/roles", "/users", "/groups", "registrations"]:
                 self.appbuilder.baseviews.remove(view)
 
+        # When legacy FAB password views are disabled, unregister their routes
+        # so direct URL access to /superset/resetpassword and 
/superset/resetmypassword
+        # is no longer possible (SPA handles password changes post-porting).
+        if not current_app.config.get("ENABLE_LEGACY_FAB_PASSWORD_VIEWS", 
False):
+            from flask_appbuilder.security.views import (
+                ResetMyPasswordView,
+                ResetPasswordView,
+            )
+
+            for view in list(self.appbuilder.baseviews):
+                if isinstance(view, (ResetPasswordView, ResetMyPasswordView)):
+                    blueprint = getattr(view, "blueprint", None)
+                    if blueprint is not None and hasattr(
+                        current_app, "unregister_blueprint"
+                    ):
+                        current_app.unregister_blueprint(blueprint)
+                    self.appbuilder.baseviews.remove(view)

Review Comment:
   Thanks. I agree this would be cleaner upstream in FAB.
   I can spin up a small FAB PR to add a config flag for security view 
registration and then update this PR accordingly.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to