Posts

Showing posts from January, 2025

Blazor: Implementing the Role Based Routing in Blazor WebAssembly

Image
In this article we will implement the Role-Based routing in Blazor WebAssembly application. In previous article , I have explained the Token Based Authentication and Policy-Based Authorization. In that article, I have explained the mechanism of using the UserName and RoleName in the JSON Web Token (JWT) claims. In the current article, we will use the same API project (I have provided the link at the end of this article.) for security and the Blazor WebAssembly project will invoke the API endpoints securely. Figure 1 shows the implementation guideline. Figure 1: The Implementation As shown in Figure 1, the execution takes place as follows: The Blazor WebAssembly client application make call to API application by sending the credentials. The API application generate JSON Web Token based on UserName and RoleName. The Token along with the UserName and RoleName is send to the client. The Blazor Application saves the Token UserName, and RoleName to Session Storage. Blazor WebAssembly cli...

ASP.NET Core 9: Implementing Secure API with Policy Based Authorization and Token Based Authentication

Image
Implementing the secure APIs is one of the most needed features of the modern applications. In the current era of the application development where APIs are used for data communication across homogeneous and heterogeneous platform application the challenge is to implement the secure communication with APIs. Thanks to ASP.NET Core for providing robust but yet easy mechanism of securing API.   Token Based Authentication Token-based authentication is a method where users verify their identity by receiving a unique access token. This token is then used to access resources without needing to re-enter credentials each time.   The Token based authentication works as follows: User Authentication : The user logs in with their credentials (e.g., username and password). The server verifies the credentials and, if valid, generates a token. 2. Token Issuance The server issues a token, which is a string that encodes the user's identity and any claims like UserName, Roles or Permissions...