Entra ID vs. custom for auth? Considering Entra ID for user management in my MERN app, but unsure about pros/cons vs. building it myself. Advice?

Saqib 20 Reputation points
2024-03-12T09:05:03.2266667+00:00

As a MERN stack developer building a feature-rich web application, I'm facing a hurdle with user authentication and authorization. While I'm confident in using MongoDB, Express.js, React.js, and Node.js for core functionalities, implementing robust security for user access feels like a complex task. Microsoft Azure's cloud services caught my eye, particularly Azure Active Directory (Azure AD). Its functionality seems like a potential solution for managing user identities in my application. However, before I delve into integrating Azure AD, I'd appreciate some insights from the MERN developer community.

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
23,747 questions
0 comments No comments
{count} votes

Accepted answer
  1. Shweta Mathur 30,261 Reputation points Microsoft Employee
    2024-03-13T05:53:27.3133333+00:00

    Hi @Saqib ,

    Thanks for reaching out.

    Microsoft Entra ID (formerly Azure AD) is a cloud-based identity and access management service that helps you secure your applications and services.

    To integrate Microsoft Entra ID with your MERN stack application, you can use the OpenID Connect protocol. This protocol allows your application to authenticate users with Entra ID and obtain information about them, such as their name and email address. Here are the high-level steps you can follow:

    1. Register your application with Entra ID: You need to create an Entra tenant and register your application with it. This will give your application an identity in Entra and allow it to authenticate users.
    2. Configure your application to use Entra ID for authentication: You need to configure your application to use the OpenID Connect protocol to authenticate users with Entra ID. This involves setting up the necessary endpoints and configuring the authentication middleware in your application.
    3. Secure your application: Once you have integrated Entra ID with your application, you can use its access control features to secure your application. This includes setting up role-based access control and enforcing multi-factor authentication.

    Refer - https://github.com/Azure-Samples/ms-identity-javascript-react-tutorial/tree/main/3-Authorization-II/1-call-api

    Here MSAL-React is used to handle the authentication of the React frontend.

    From your React frontend, you call your Node.js API passing the accessToken acquired with the help of MSAL.

    Passport.js is used on the Node.js API to validate the accessToken

    Hope this will help to start with. If you have any further queries, please let us know to help you further.

    Thanks,

    Shweta

    Please remember to "Accept Answer" if answer helped you.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.