Skip to main content

Posts

Part-1 Angular JWT Authentication Using HTTP Only Cookie[Angular V13]

In this article, we are going to implement a sample angular application authentication using HTTP only cookie that contains a JWT token. HTTP Only JWT Cookie: In a SPA(Single Page Application) Authentication JWT token either can be stored in browser 'LocalStorage' or in 'Cookie'. Storing JWT token inside of the cookie then the cookie should be HTTP Only. The HTTP-Only cookie nature is that it will be only accessible by the server application. Client apps like javascript-based apps can't access the HTTP-Only cookie. So if we use authentication with HTTP only JWT cookie then we no need to implement custom logic like adding authorization header or storing token data, etc at our client application. Because once the user authenticated cookie will be automatically sent to the server by the browser on every API call. Authentication API: To implement JWT cookie authentication we need to set up an API. For that, I had created a mock authentication API(Using the NestJS Se

Built-in DynamicComponent Blazor Component[.NET6 Feature]

In this article, we will understand about a .NET6 feature that is built-in 'DynamicComponent' in the Blazor application. DynamicComponent: In Blazor from .NET6 introduced a built-in component that is 'DynamicComponent' for dynamic rendering of the razor components. So using DynamicComponent we can render different types of components very easily without using any conditional logic. Also can pass appropriate parameters to their respective components on rendering dynamically. Create A .NET6 Blazor WebAssembly Application: Let's create a .Net6 Blazor WebAssembly sample application to accomplish our demo. We can use either Visual Studio 2022 or Visual Studio Code(using .NET CLI commands) to create any.Net6 application. For this demo, I'm using the 'Visual Studio Code'(using the .NET CLI command) editor. CLI command dotnet new blazorwasm -o Your_Project_Name Example Using DynicComponent: By default on creating project we have 3 components like

.NET6 Razor Pages CRUD Operations With Entity Framework Core

In this article, we will do a small demo of the AspNetCore 6 Razor Pages CRUD operation. Razor Pages: Razor Page is a simplified web application model. On comparing with the 'MVC' template, razor pages won't have 'Controller', which means Razor Page is a combination of 'View' and 'Model'. Routing itself is configured within the page or view. A Razor Page mostly contains 2 files like '*.cshtml'(View) and '*.cshtml.cs'(model). Create A .NET6 Razor Pages Application: Let's create a .Net6 Razor Page sample application to accomplish our demo. We can use either Visual Studio 2022 or Visual Studio Code(using .NET CLI commands) to create any.Net6 application. For this demo, I'm using the 'Visual Studio Code'(using the .NET CLI command) editor. CLI command dotnet new webapp -o Your_Project_Name Let's explore the project to understand its structure: (1) Let's understand the initial services registered in 'Progr

Implementing AspNetCore Identity Authentication In To An Existing Blazor Server App[.NET6]

In this article, we will implement AspNetCore Identity Authentication into an existing Blazor Server app. Microsoft AspNetCore Identity Library: AspNetCore Identity: Built-in login functionality library that supports authentication of all different .NET applications. Provides rich authentication UI pages and customizable as well. Adoptable for external authentication providers like 'Google', 'Facebook', 'Outlook'. Can be integrated with other authentications like 'IdentityServer4', 'Azure Active Directory', 'Azure Active Directory B2C(Azure AD B2C)'. Blazor Server Project With No Authentication: Our goal is to implement the AspNetCore Identity Authentication manually into an existing Blazor Server application(the project doesn't have authentication). So to accomplish our demo let's create a Blazor server application without any authentication. We can use either Visual Studio 2022 or Visual Studio Code(using .NET CLI commands)