dotnet/systemweb-adapters

Improve documentation for remote authentication with Blazor

joepetrakovich opened this issue · 2 comments

I'm trying to set up remote authentication with a Blazor Server app alongside a legacy Web Forms app that uses Forms Authentication but there are some missing pieces that I can't quite figure out.

The docs, other docs suggest that "the ASP.NET Core app will see the identity of users logged in to the ASP.NET app and if the ASP.NET Core app challenges authentication, it should redirect to the login page of the ASP.NET app" but it seems like this only applies to ASP.NET Core controller routes.

In Blazor, when I set everything up and use an [Authorize] attribute on a razor page in conjunction with a AuthorizeRouteView, it does seem to properly detect if I am logged into the legacy app and shows the appropriate view if not, however there is no automatic routing to the legacy login page (and thus no subsequent redirect after logging in).

Is there something I've misconfigured or do I need to manually set this up somehow? Some docs would be great.

I tried setting up the RedirectToLogin component mentioned here with a manual navigation to the legacy login page, but it's missing the redirect url behavior that comes with Forms Authentication on the legacy app.

Edit:

I was able to get this to work by manually creating the return url via this suggestion. I don't know if it's worth closing this if there's a better way.

Thanks for logging the issue @joepetrakovich. @JeremyLikness after taking a look at the above description, seems like the confusion here is not necessarily tied to systemweb-adapters themselves, but more of trying to find documentation of how to set a redirect URL and a login URL when using Authentication in a blazor server app. Do we have any docs for that? @joepetrakovich is my previous statement correct that this is not specific to systemweb-adapters? If so I'm inclined to move this issue to the aspnetcore repo instead.

@JeremyLikness yeah that's correct. It's more about documentation of remote authentication in tandem with incremental migration and blazor.