Blazor immediate authorization

Viewed 53

I have a Blazor WASM(hereinafter app), ASP Hosted project with identity server authorization. I need the user must log in before showing app. So I in NotAuthorized section of AuthorizeRouteView in App.razor add redirect to login.

The problem with this approach is that the app loads first, redirects to a login page that is not part of the application, and after logging in, redirects back and reloads the entire app, which significantly slows down the initial process of logging in and launching the application.

So my question is: Is there a better solution which avoid double loading of the whole app?

1 Answers

If you want to authenticate before loading the app, the check needs to be outside of the app. If you have a hosted server, you can use Static File Authorization at the server level. If you don't have a hosted server, a popup authorization could be an alternative, but it's not support OOB by Identity Server AFAIK. There are others who are trying/using that approach.

Related