A secure Node.js web application implementing Microsoft Entra ID (Azure AD) authentication with a minimalist black interface.
- Single Sign-On with Microsoft Entra ID
- Secure session management
- Rate limiting and security headers
- Comprehensive logging
- Automated deployment to Azure Web App
- Node.js 18.x or later
- Microsoft Azure account
- Microsoft Entra ID (Azure AD) application registration
- Azure Web App service
- GitHub account (for deployment)
- Clone the repository:
git clone [repository-url]
cd [repository-name]
- Install dependencies:
npm install
- Create a
.env
file in the root directory with the following variables:
CLIENT_ID=your_client_id
TENANT_ID=your_tenant_id
CLIENT_SECRET=your_client_secret
REDIRECT_URI=http://localhost:3000/auth/callback
SESSION_SECRET=your_session_secret
- Start the development server:
npm run dev
The application will be available at http://localhost:3000
- Go to the Azure Portal (https://portal.azure.com)
- Navigate to Microsoft Entra ID > App registrations
- Click "New registration"
- Enter application details:
- Name: Your app name
- Supported account types: Single tenant
- Redirect URI: http://localhost:3000/auth/callback (for development)
- After registration, note down:
- Application (client) ID
- Directory (tenant) ID
- Under "Certificates & secrets":
- Create a new client secret
- Copy the secret value immediately
Variable | Description |
---|---|
CLIENT_ID | Microsoft Entra ID Application (client) ID |
TENANT_ID | Microsoft Entra ID Directory (tenant) ID |
CLIENT_SECRET | Microsoft Entra ID client secret |
REDIRECT_URI | Authentication callback URL |
SESSION_SECRET | Secret for session encryption |
Set the following secrets in your GitHub repository:
- CLIENT_ID (Microsoft Entra ID Application Client ID)
- TENANT_ID (Microsoft Entra ID Tenant ID)
- CLIENT_SECRET (Microsoft Entra ID Client Secret)
- REDIRECT_URI (Authentication callback URL)
- SESSION_SECRET (Session encryption key)
The following secrets are automatically configured when you connect your GitHub repository to Azure Web App:
- AZUREAPPSERVICE_CLIENTID_{ID}
- AZUREAPPSERVICE_TENANTID_{ID}
- AZUREAPPSERVICE_SUBSCRIPTIONID_{ID}
- Create an Azure Web App in the Azure Portal
- In the Azure Web App, go to Deployment Center
- Select GitHub as the source and connect your repository
- Azure will automatically configure the deployment workflow and required secrets
- Add the application secrets to GitHub Secrets
- Push to main branch to trigger deployment
├── .github/
│ └── workflows/
│ └── main_entraidlogin.yml
├── documents/
│ ├── api.md
│ ├── architecture.md
│ └── security.md
├── public/
│ ├── index.html
│ └── welcome.html
├── app.js
├── package.json
└── README.md
- Content Security Policy (CSP)
- Security headers via Helmet
- Rate limiting
- Secure session management
- Input validation
- Error handling
- Comprehensive logging
Detailed documentation is available in the documents
folder:
# Install dependencies
npm install
# Run in development mode
npm run dev
# Run in production mode
npm start
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.