1- # 🔹 NodeJS-API: Active Directory SSO Integration
1+ # 🔹 NodeJS-API — Active Directory SSO Integration
22
3- ## 📌 Overview
3+ ![ SSO] ( https://img.shields.io/badge/SSO-LDAP%20%7C%20Active%20Directory-blue?style=for-the-badge&logo=microsoft )
4+ ![ NodeJS] ( https://img.shields.io/badge/Node.js-Express-339933?style=for-the-badge&logo=node.js&logoColor=white )
5+ ![ API] ( https://img.shields.io/badge/Type-REST%20API-0A66C2?style=for-the-badge )
6+ ![ Security] ( https://img.shields.io/badge/Security-Enterprise%20SSO-critical?style=for-the-badge )
47
5- The ** NodeJS-API** module enables ** LDAP-based Single Sign-On (SSO)** authentication with ** Active Directory** using the ` passport-ldapauth ` strategy and Express.
6- It allows ** secure authentication and user query operations** directly from an LDAP directory.
8+ ## 📝 Overview
9+
10+ The ** NodeJS-API** module provides a ** Node.js + Express–based REST API** that implements ** LDAP-based Single Sign-On (SSO)** authentication against ** Microsoft Active Directory** using the ` passport-ldapauth ` strategy.
11+
12+ This module follows the same ** security, configuration, and architectural standards** defined across the ** ActiveDirectory-SSO-Integrations** suite, enabling ** consistent, auditable, and reusable SSO integrations** across heterogeneous application stacks.
13+
14+ Primary objectives:
15+
16+ - Centralized authentication via Active Directory
17+ - Secure LDAP bind using ** least-privilege service accounts (InetOrgPerson)**
18+ - Middleware-enforced authentication flow
19+ - Token-ready API design for enterprise applications
720
821---
922
1023## 📁 Folder Structure
1124
1225```
1326ActiveDirectory-SSO-Integrations/
14- │
15- ├── 📂 NodeJS-API/ # Parent folder for Node.js API integration
16- │ ├── 📜 package.json # Project dependencies and startup script
17- │ ├── 📁 app.js # Main application file
18- │ ├── 📂 config/ # Configuration folder
19- │ │ ├── 📜 ldap.config.json # LDAP configuration
20- │ ├── 📂 controllers/ # API controllers
21- │ │ ├── 📜 authController.js # Authentication logic
22- │ │ ├── 📜 userController.js # User info retrieval
23- │ ├── 📂 middleware/ # Middleware logic
24- │ │ ├── 📜 ldapAuthMiddleware.js # Enforces authentication
25- │ ├── 📂 routes/ # Express routes
26- │ │ ├── 📜 authRoutes.js # Routes for login
27- │ │ ├── 📜 userRoutes.js # Routes for user data
28- │ ├── 📂 utils/ # Utility functions
29- │ │ ├── 📜 logger.js # Event logging
30- │ ├── 📖 README.md # Documentation
27+ └── NodeJS-API/
28+ ├── package.json
29+ ├── app.js
30+ ├── config/
31+ │ └── ldap.config.json
32+ ├── controllers/
33+ │ ├── authController.js
34+ │ └── userController.js
35+ ├── middleware/
36+ │ └── ldapAuthMiddleware.js
37+ ├── routes/
38+ │ ├── authRoutes.js
39+ │ └── userRoutes.js
40+ ├── utils/
41+ │ └── logger.js
42+ └── README.md
3143```
3244
3345---
3446
3547## 🛠️ Prerequisites
3648
37- - ** Node.js 16+ and npm**
38- - ** Active Directory instance ** accessible via LDAP
39- - ** LDAP credentials with read permissions **
40- - ** Postman or cURL ** ( for API testing)
49+ - Node.js ** 16+** and npm
50+ - Active Directory domain with LDAP enabled
51+ - Dedicated LDAP bind account (InetOrgPerson, least privilege)
52+ - Postman or curl for API testing
4153
4254---
4355
44- ## ⚙️ Configuration
56+ ## ⚙️ LDAP Configuration
4557
46- Modify ` config/ldap.config.json ` with your ** LDAP credentials ** :
58+ Edit ` config/ldap.config.json ` and configure LDAP parameters :
4759
4860``` json
4961{
@@ -57,94 +69,49 @@ Modify `config/ldap.config.json` with your **LDAP credentials**:
5769}
5870```
5971
60- ---
61-
62- ## 🚀 How to Run
63-
64- 1 . ** Clone the repository** :
65- ``` bash
66- git clone https://github.com/brazilianscriptguy/Windows-SysAdmin-ProSuite.git
67- cd Windows-SysAdmin-ProSuite/SysAdmin-Tools/ActiveDirectory-SSO-Integrations/NodeJS-API
68- ```
69-
70- 2 . ** Set the LDAP password as an environment variable** :
71- ``` bash
72- export LDAP_PASSWORD=' your-secure-password'
73- ```
74-
75- 3 . ** Install dependencies** :
76- ``` bash
77- npm install
78- ```
79-
80- 4 . ** Start the application** :
81- ``` bash
82- npm start
83- ```
84-
85- 5 . The API will be available at ` http://localhost:3000 ` .
72+ > 🔐 ** Security note:** never store credentials in source code. Inject ` LDAP_PASSWORD ` via environment variables or a secure secrets manager.
8673
8774---
8875
89- ## 🔄 API Endpoints
76+ ## 🚀 Running the API
9077
91- ### 1️⃣ Authenticate User
78+ ``` bash
79+ git clone https://github.com/brazilianscriptguy/Windows-SysAdmin-ProSuite.git
80+ cd Windows-SysAdmin-ProSuite/SysAdmin-Tools/ActiveDirectory-SSO-Integrations/NodeJS-API
81+ ```
9282
93- - ** Endpoint** : ` POST /api/auth/login `
94- - ** Request Body** :
95- ``` json
96- {
97- "username" : " john.doe" ,
98- "password" : " SuperSecretPassword"
99- }
100- ```
101- - ** Response** :
102- ``` json
103- {
104- "message" : " Authentication successful" ,
105- "token" : " eyJhbGciOiJIUzI1..."
106- }
107- ```
83+ ``` bash
84+ export LDAP_PASSWORD=" your-secure-password"
85+ npm install
86+ npm start
87+ ```
10888
109- ---
110-
111- ### 2️⃣ Get User Details
112-
113- - ** Endpoint** : ` GET /api/user/:username `
114- - ** Example Request** :
115- ``` bash
116- curl -X GET http://localhost:3000/api/user/john.doe
117- ```
118- - ** Response** :
119- ``` json
120- {
121- "username" : " john.doe" ,
122- "displayName" : " John Doe" ,
123- 124- "department" : " IT" ,
125- "role" : " User"
126- }
127- ```
89+ The API will be available at ` http://localhost:3000 ` .
12890
12991---
13092
131- ## 📜 License
93+ ## 🔄 API Endpoints
13294
133- [ ![ MIT License] ( https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge )] ( https://github.com/brazilianscriptguy/Windows-SysAdmin-ProSuite/blob/main/.github/LICENSE.txt )
95+ ### Authenticate User
96+ ` POST /api/auth/login `
13497
135- ---
98+ ### Retrieve User Details
99+ ` GET /api/user/:username `
136100
137- ## 🤝 Contributing
138-
139- [ ![ Contributions Welcome] ( https://img.shields.io/badge/Contributions-Welcome-brightgreen?style=for-the-badge )] ( https://github.com/brazilianscriptguy/Windows-SysAdmin-ProSuite/blob/main/.github/CONTRIBUTING.md )
101+ Example:
102+ ``` bash
103+ curl -X GET http://localhost:3000/api/user/john.doe
104+ ```
140105
141106---
142107
143- ## 📩 Support
108+ ## 🔐 Security Notes
144109
145- [ ![ Email Badge
] ( https://img.shields.io/badge/[email protected] ?style=for-the-badge&logo=gmail )] ( mailto:[email protected] ) 146- [ ![ GitHub Issues] ( https://img.shields.io/badge/GitHub%20Issues-Report%20Here-blue?style=for-the-badge&logo=github )] ( https://github.com/brazilianscriptguy/Windows-SysAdmin-ProSuite/blob/main/.github/BUG_REPORT.md )
110+ - LDAP bind uses ** least-privilege service account**
111+ - Interactive logon disabled for bind account
112+ - Authentication enforced via middleware
113+ - Designed for on‑premises, hybrid, or containerized deployments
147114
148115---
149116
150- < p align = " center " >🚀 < strong >Enjoy Seamless SSO Integration!</ strong > 🎯</ p >
117+ © 2026 Luiz Hamilton Silva. All rights reserved.
0 commit comments