MSAL Integration in React + .Net App For all Microsoft Users (Without registering or Inviting the User)

304 Views Asked by At

How to Integration MSAL in React + .Net App For all Microsoft Users (Without registering or Inviting the User)

I have implemented it for a specific tenant, but in that, I always need to register a user or invite a user for that user to access the Application, but I want all the Microsoft users to access the token, so that I can use that token to Login into the .net application.

1

There are 1 best solutions below

0
Kartik Bhiwapurkar On

• I would suggest you to please implement React JS web application running on Node.js in frontend and ASP .NET Core API application in the backend as well as deploy a Microsoft SQL server as a database server such that the user’s information should be stored in the database upon creation. Thus, as per your desired configuration that all the Microsoft users should be able to access the token and then you should be able to login to the backend .NET application, you should integrate Azure AD B2C tenant with your frontend react JS web application along with MSAL authentication as described in the below documentation. It also describes that you will have to register an application in Azure AD B2C for authentication purpose and integrate its details in the react app. Also, you will have to configure the user flows and the custom policies accordingly for ensuring that when the guest user logs into the React MSAL app, its details are stored in the Azure AD B2C tenant and from there, they can be exported to the SQL database.

https://learn.microsoft.com/en-us/azure/active-directory-b2c/configure-authentication-sample-web-app?tabs=visual-studio

• Once, the above has been done, ensure that the backend application is integrated with Azure SQL by delegating the application created in Azure AD B2C, the required permissions for that concerned Azure resource (SQL database) for allowing to access the same and retrieve the user details from it. Thus, in this way, you can configure your application accordingly. Further which, you can use the user details to generate a token and login to the desired application.

Kindly refer the below documentation link for more details: -

https://www.codeproject.com/Articles/1121503/Integrate-Azure-AD-B-C-with-ASP-NET-MVC-Web-App-Pa

P.S.: - Please note that a token generated for a user for that particular app is for a limited time and may be, you cannot also reuse it.

Also, find the below community thread for your reference: -

Where to implement Azure AD B2C with React frontend and ASP.NET Core 6 backend