Do you want to learn how to add authentication to your Node.js application? In this step-by-step tutorial, you will learn how to integrate a Node.js application with Azure AD using Datawiza to implement OIDC/OAuth SSO for the Node.js application.
What is a Node.js application?
Run a Node.js application
We use the sample offered in Node.js official Getting Started Guide as the example in this section. The application running at port 3000 simply returns “Hello World.”
What is the best Node.js authentication library? Passport, which has 19,131 stars in Github, is extremely flexible and modular. It has a comprehensive set of strategies supporting authentication using a username and password, Facebook, Twitter, and more. What’s more, it has a plugin for Azure Active Directory. However, you still need to spend a lot of time to clearly understand the concepts about Azure AD, OIDC, Oauth2, and so on. You deserve a better solution, and we are building one that will reduce the time required down to hours or days, even minutes.
Introduction to the Datawiza Platform
The Datawiza Platform is a cloud-delivered, SaaS-based access management solution. It includes a data plane and a control plane: Datawiza Access Broker (DAB) and Datawiza Cloud Management Console (DCMC).
DAB is a lightweight, container-based access proxy deployed close to your application via the sidecar (agent) or gateway mode. It talks to Azure AD on behalf of your applications, so you don’t need to worry about the integration work. DCMC is a cloud-based management console where you can configure and manage the policies of DABs. Such a SaaS-based design makes the whole platform much easier to use.
Simple configurations using Datawiza Cloud Management Console
Use your Azure AD Admin Account (this account should have the permission to create an app registration in the Azure AD tenant) to log in to the DCMC.
Follow the tutorial in Integrating a web application with Azure AD using Datawiza in 5 mins to create an application in DCMC. Note that when you configure the application, the port of Upstream Servers should be 3000 instead of 3001:
Run DAB as a sidecar (agent) to your application
After finishing the configuration in DCMC, you can run the DAB with the YAML file noted in the previous step. The docker-compose YAML file should then be like this:
Now, we can use docker-compose to create and start the DAB:
docker-compose -f datawiza-access-broker up -d
That's it. After executing the command above, the Node.js application should have SSO enabled with Azure AD.
Now, let's give it a try.
Open a browser and type in http://localhost:9772. You should see the Azure AD login page as follows. Note that if you are already logged into Azure AD in your browser, you may need to logout to see the login page.
After logging in to Azure AD, the Node.js application will be shown.
This tutorial has shown you how to secure a Node.js application with Azure AD using Datawiza -- in minutes instead of hours or days. Get a free trial by signing in here. Please email us at firstname.lastname@example.org if you need any help or have any questions.