Reputation: 775
I am trying to create a basic User Management module in my software and I have followed this guide to create the module:
I suppose this is the best practice recommended by Microsoft. However, I do not understand the following:
Upvotes: 5
Views: 1464
Reputation: 546
Authentication and authorization should always be handled by the backend because the frontend can always be manipulated or emulated. If you follow these instructions, authorization will be fully handled by the server side. The login and logout functionality will redirect you to razor pages running on the server. When the user is authenticated, a JWT is created and sent to your Blazor application. This token can then be used to send authentication information along with subsequent HTTP requests. It's a bit tricky to get this approach up and running, but it works well.
The identity server used in these examples is part of ASP.NET.
IdentityServer and IdentityServer4 are referring to the IdentityServer that is included in ASP.NET.
You may also use Cookie-based authentication and create a Web API to handle login/logout and provide user information. It is easy to set-up and to provide Blazor UIs for authentication. Make sure to have an encrypted connection when using this approach because you need to send login information via HTTP request.
Anyway, I personally would stick to the Microsoft recommendations and use JWT.
Upvotes: 2