Skip to main content

Posts

Part-5 | Asp.Net Core Identity Series[.NET 7] | Google Authentication

The main objective of this article is: Implementing Google Authentication Install Google Authentication NuGet Package: Let's install the package required for google authentication. Visual Studio 2022: Install-Package Microsoft.AspNetCore.Authentication.Google -Version 7.0.3 Visual Studio Code: dotnet add package Microsoft.AspNetCore.Authentication.Google --version 7.0.3 Register With Google: We need to register our Razor Page application with Google to enable Google authentication. So following are the registration steps with Google. (Step 1) Go to Google API & Service could console at "https://console.cloud.google.com/projectselector2/apis/dashboard?supportedpurview=project" (Step 2) Click on the 'Create Project' button. (Step 3) Give a project name and then click on the 'Create' button. (Step 4) On creating a project successfully, we can observe it as a selected project in our dashboard like below. (Step 5) Select 'OAuth Consent Screen' l

Vue(3.0) Composition API | Bootstrap(v5) | JSON Server | CRUD Example

In this article, we are going to implement a sample Vue(3.0) CRUD example, using JSON Server(Fake API). Vue(3.0): Vue(3.0) is a javascript framework for creating a single-page application. Vue application built by component. The components are the smallest unit of the application which comprises 'Script', 'Template(HTML)', and 'Style'. Eventually, multiple components together create the Vue application. Create Vue(3.0) Application: Let's create a sample Vue(3.0) application to accomplish our demo. To create a VueJS application our local machine should contain NodeJS. So go to "https://nodejs.org/en/download" and download the Node. Now run the below command to create the Vue3 application.  npm init vue@latest On running the above command we have to choose a few options before creating a vue application, in those options we can choose the default option as 'No', but for the routing option select 'Yes' like below. Now open our v

Part-4 | Asp.Net Core Identity Series[.NET 7] | Sending Two-Factor Authentication(2FA) Code To Phone

The main objectives of this article are: Sending Two-Factor Authentication(2FA) Code to Phone Enable Phone 2FA: In the Asp.Net Core Identity application to enable 'Phone' Two-Factor Authentication, ensure our 'AspNetUser' table following fields has appropriate data: PhoneNumber - Should have valid phone number along with country code PhoneNumberConfirmed - must be true TwoFactorEnabled - must be true Twilio Setup: Twilio is a third-party service provider which provides services like SMS, Voice Calls, Chats, etc. (Step 1) Go to the Twilio website 'https://www.twilio.com/' and SignUp. (Step 2) Now Login => We entered into the Twilio console dashboard => Here create a project and you will get 'Account SID', 'Auth Token', and 'My Twilio Phone Number(which will be our From Phone Number). (Step 3) I'm going to use the Free credits to set up the SMS service. So here is one limitation with free credits we have to register all testing &

Part-3 | Asp.Net Core Identity Series[.NET 7] | Sending Two-Factor Authentication(2FA) Code To Email

The main objectives of this article are: Sending Two-Factor Authentication(2FA) Code To Email Enable Email 2FA: In Asp.Net Core Identity application to enable email Two-Factor Authentication, make sure our 'AspNetUser' table following fields has appropriate data: Email - Should not be empty or null EmailConfrimed - must be true TwoFactorEnabled - must be true. Now if we try to login into our application we can see a page to enter the 2FA code like below Send Two-Factor Authentication(2FA) Code To Email: Now let's update the code in 'OnGetAsync()' method in 'Areas/Identity/Pages/Account/LoginWith2faModel.cshtml.cs' as below. Areas/Identity/Pages/Account/LoginWith2faModel.cshtml.cs: public async Task<IActionResult> OnGetAsync(bool rememberMe, string returnUrl = null) { // Ensure the user has gone through the username & password screen first var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); if (user == null) { throw ne