-
Notifications
You must be signed in to change notification settings - Fork 10.3k
.NET 7 Blazor WASM authentication back button history behavior still problematic with 3rd party IDP #45097
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
Comments
@mikequ-taggysoft thanks for contacting us. The code to do this is in your app. Essentially inside the RedirectToLogin component, you can replace the navigation entry that goes to manager.NavigateTo(loginPath, new NavigationOptions
{
ReplaceHistoryEntry = true,
HistoryEntryState = new InteractiveRequestOptions
{
Interaction = InteractionType.SignIn,
ReturnUrl = manager.Uri
}.ToState()
}); |
@javiercn You meant to replace the |
This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes. See our Issue Management Policies for more information. |
Hi @mikequ-taggysoft. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
@javiercn Thanks so much for re-opening and helping me out with this! So yeah after I serialized the Now yesterday when I realized that
And So I guess not passing this P.S, when I looked at the source codes for the
The only difference with the code you showed me was to add the I personally think the final behavior I proposed and you helped me achieve here should be the "ideal" default, out-of-the-box behavior for most use cases (avoiding authentication loop via back button press), that could warrant a documentation/default code update. What do you think? |
Yep.
I would be ok if we add this option to the helper methods, but I do not think is the correct default. That works when some part of your app does not require auth, but it does not when all your app requires authorization. |
The remaining work here is to add an overload that takes a boolean we apply to |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Summary
.NET 7 improved Blazor WASM's authentication back history behavior in pull #43954. The underlying issue was described in issue #43063 @javiercn
However, after testing the new implementation, I'm still not getting the desirable behavior: back button returns to previous page that does not require authentication.
Motivation and goals
Consider the following typical scenario:
@attribute [Authorize]
app.razor
sees that this is a protected route, and redirects user to contoso.com/Authentication/login via theRedirectToLogin
Blazor component.However, in reality, the back button brings the user to contoso.com/protected, which then redirects the user to /Authentication/login and finally the IDP login page again, still resulting in a loop.
I believe this is a bit better than the previous version, where the back button would bring the user to /Authentication/login which would trigger a failure message.
But I think it would be a much better experience if the new history state manager can store the URL the user was on before the protected page was requested that triggered authentication, and bring the user to that page accordingly when back button is clicked.
The text was updated successfully, but these errors were encountered: