fix: distinguish authentication from authorization redirects - #2479
Open
aminghadersohi wants to merge 2 commits into
Open
fix: distinguish authentication from authorization redirects#2479aminghadersohi wants to merge 2 commits into
aminghadersohi wants to merge 2 commits into
Conversation
9 tasks
| def login(self): | ||
| if g.user is not None and g.user.is_authenticated: | ||
| return redirect(self.appbuilder.get_url_for_index) | ||
| return redirect(self._get_safe_next_url()) |
| def login(self): | ||
| if g.user is not None and g.user.is_authenticated: | ||
| return redirect(self.appbuilder.get_url_for_index) | ||
| return redirect(self._get_safe_next_url()) |
| if g.user is not None and g.user.is_authenticated: | ||
| log.debug("Already authenticated %s", g.user) | ||
| return redirect(self.appbuilder.get_url_for_index) | ||
| return redirect(self._get_safe_next_url()) |
| def login(self, idp: Optional[str] = None) -> WerkzeugResponse: | ||
| if g.user is not None and g.user.is_authenticated: | ||
| return redirect(self.appbuilder.get_url_for_index) | ||
| return redirect(self._get_safe_next_url()) |
| if g.user is not None and g.user.is_authenticated: | ||
| next_url = request.args.get("next", "") | ||
| return redirect(get_safe_redirect(next_url)) | ||
| return redirect(self._get_safe_next_url()) |
aminghadersohi
marked this pull request as ready for review
September 4, 2026 05:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This changes FAB's browser-auth behavior so authentication and authorization failures are no longer treated as the same condition:
@has_accessstill flashes the existing message and redirects to/login/?next=<requested URL>;403response rather than redirecting to login;nextURL instead of discarding it. This is applied consistently to DB, LDAP, OAuth, SAML, and Remote User auth views. Missing or unsafe destinations continue to fall back to the application index.This is intentionally a draft and explicitly invites maintainer discussion: returning
403instead of302for authenticated users is a behavior change, but it avoids redirect loops and aligns MVC behavior with the existing distinction made by@has_access_api.The fix was split out of Apache Superset PR #43606, following Vitor Avila's suggestion to address the coupled behavior in FAB. It relates to Preset Shortcut story 97504.
The separate backslash redirect-safety issue discussed on the Superset PR is deliberately not included here; it is being handled separately.
Tests cover the
403response and redirect behavior across every FAB browser auth view, including rejection of an externalnextdestination. The changelog is updated because this affects application-visible behavior.Testing
ADDITIONAL INFORMATION