Skip to content
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

Equivalent to LocalRedirect in Blazor #49628

Open
danroth27 opened this issue Jul 25, 2023 · 3 comments
Open

Equivalent to LocalRedirect in Blazor #49628

danroth27 opened this issue Jul 25, 2023 · 3 comments
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-blazor-navigation
Milestone

Comments

@danroth27
Copy link
Member

In MVC & Razor Pages you can all LocalRedirect() to trigger a redirect to page in the app. This is typically used with return URLs specified in the request, so that a malicious request can't send you off to some other site.

In Blazor we have NavigationManager.NavigateTo(). Do we need a NavigateToLocal()?

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Jul 25, 2023
@javiercn
Copy link
Member

@danroth27 thanks for contacting us.

It's not that relevant, since the main use case is redirects in auth. In other scenarios you can implement this with a few lines of code:

var relative = navigationManager.ToBaseRelativeUri(uri);
if(relative == uri){
   throw new invalidoperationexception
}
navigationManager.NavigateTo(relative);

@mkArtakMSFT mkArtakMSFT added the enhancement This issue represents an ask for new feature or an enhancement to an existing one label Jul 26, 2023
@mkArtakMSFT mkArtakMSFT added this to the Backlog milestone Jul 26, 2023
@ghost
Copy link

ghost commented Jul 26, 2023

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.

@danroth27
Copy link
Member Author

danroth27 commented Jul 27, 2023

It seems incorrect to me to throw in this case. This is a problem with the request, not a necessarily a server error. However, it does appear that LocalRedirect throws and ToBaseRelativePath will throw if the passed in URI is not relative to the base URI. So the behavior is consistent.

@mkArtakMSFT mkArtakMSFT modified the milestones: Backlog, BlazorPlanning Nov 5, 2023
@mkArtakMSFT mkArtakMSFT modified the milestones: Planning: WebUI, Backlog Nov 27, 2023
@dotnet dotnet deleted a comment Nov 27, 2023
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-blazor-navigation
Projects
None yet
Development

No branches or pull requests

4 participants