Skip to main content

Posts

Showing posts with the label Authorization

Part-1 Blazor WebAssembly Cookie Authentication[.NET 6]

In this article, we are going to authenticate our Blazor WebAssemably application with simple Asp.NetCore cookie. Targets Of Blazor WebAssembly Cookie Auth Series: Let's have look at this Blazor WebAssmbly series: Part -1 is simple asp.net core cookie authentication. Part-2 is cookie authentication with FaceBook. Part-3 is cookie authentication with Twitter. Part-4 is cookie authentication with Google. Part-5 is cookie authentication with Microsoft. Blazor WebAssembly Cookie Authentication Flow: We must have 2 applications 'Blazor WebAssembly Application'(which runs on the user browser), and 'Asp.Net Core API'(which runs on the server). Blazor WebAssembly requests the API for user authentication by sending the user credentials to API. For valid credentials, API generates auth cookie and sends it to the client application. So after successful authentication of every request from Blazor WebAssembly to API, the auth cookie will be attached to every subsequent request

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)

Blazor Server Authentication And Authorization Using Microsoft AspNetCore Identity[.NET6]

In this article, we are going to do a small demo on Blazor Server authentication and authorization using Microsoft AspNetCore Identity. 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 authentication like 'IdentityServer4', 'Azure Active Directory', 'Azure Active Directory B2C(Azure AD B2C)'. Create A .NET6 Blazor Server App With Individual Authentication: Let's create a .Net6 Blazor Server sample application with individual authentication 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

Part-2 Hot Chocolate GraphQL Validate JWT Access Token And Different Authorization Techniques

Part-1  completely discussed the steps to generate the access token in the GraphQL endpoint. Now in this article, our main goals are to validate the JWT access token and also we try to understand authorization techniques in GraphQL. Install JwtBearer Authentication NuGet: Let's install JwtBearer Authentication NuGet to configure JwtBearer services. .Net CLI Command: dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer Package Manager Command: Install-Package Microsoft.AspNetCore.Authentication.JwtBearer Register JWT Validation Service: Now we need to register the JwtBearer service to validate our access token on the user sending the access token as an authorization header. Startup.cs: using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.IdentityModel.Tokens; services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters { ValidIssuer = Con