rusackas commented on code in PR #44857:
URL: https://github.com/apache/superset/pull/44857#discussion_r4153062336
##########
superset/security/password_change.py:
##########
@@ -170,6 +170,36 @@ def _is_exempt_endpoint(endpoint: Optional[str]) -> bool:
return view_class in _EXEMPT_VIEW_CLASSES
+def _profile_page_reachable(security_manager: Any) -> bool:
+ """Return whether the current user can reach ``UserInfoView.list``.
+
+ It requires ``can_read`` on ``user``, which ``sync_role_definitions`` only
+ grants to the built-in Admin/Alpha/Gamma roles -- a custom role is never
+ guaranteed to hold it. A user without it who gets redirected there hits
+ FAB's own access-denied redirect (to login), which, since they're already
+ authenticated, bounces straight back to the index -- which re-runs this
+ hook and redirects to the profile page again, looping forever.
+ """
+ return security_manager is not None and bool(
+ security_manager.has_access("can_read", "user")
+ )
+
+
+def _logout_fallback_candidates(security_manager: Any) -> list[str]:
+ """Build the ordered list of logout endpoints to try as a last resort."""
+ candidates = []
+ auth_view = getattr(security_manager, "auth_view", None)
+ # Only redirect to the registered auth view's logout if that view is
+ # itself exempt from this hook; otherwise the redirect would loop.
+ if (
+ auth_view is not None
+ and getattr(auth_view, "endpoint", None) in _EXEMPT_VIEW_CLASSES
+ ):
+ candidates.append(f"{auth_view.endpoint}.logout")
+ candidates.append("AuthDBView.logout")
Review Comment:
self.auth_view ends up being the native per-backend view
(AuthDBView/AuthLDAPView/AuthOAuthView/etc.), not SupersetAuthView. FAB's own
register_views() reassigns it right after this file sets it, and those view
classes are already in the exempt set.
--
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]