This package provides Express middleware specifically designed for authenticating HTTP requests using JSON Web Tokens (JWTs) issued by Azure Active Directory (AAD). It streamlines the process of validating incoming JWTs and, upon successful validation, decodes the token and attaches the resulting JSON object to `req.user` (or a configurable property like `req.auth`). This allows subsequent middleware or route handlers to easily access user information for authorization and access control. The current stable version, 0.2.2, was released several years ago, indicating the project is likely no longer actively maintained. Its primary differentiation lies in its explicit focus on Azure AD JWT validation within the Express framework, simplifying integration for applications within the Microsoft ecosystem.
npm install express-azure-jwtVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up an Express application with `express-azure-jwt` to protect routes using Azure AD JWTs, including error handling for unauthorized access and defining unprotected paths.
Consider migrating to a more actively maintained authentication library for Azure AD, such as `@azure/msal-node` or Passport.js strategies like `passport-azure-ad`.
Ensure your application exclusively uses Azure AD as its identity provider. For other providers, use a more generic or provider-specific JWT validation library.
For new projects, prefer ESM-native libraries. If using this package, ensure your build setup correctly handles CommonJS modules or use `require()` imports directly.
Always implement Express error handling middleware (`app.use(function(err, req, res, next) { ... })`) to specifically catch and gracefully handle `err.name === 'UnauthorizedError'`.Ensure the client sends an 'Authorization' header in the format `Authorization: Bearer <YOUR_JWT_TOKEN>` for protected routes.
Verify that the JWT is correctly signed, has not expired, and matches the expected issuer and audience configured in the `express-azure-jwt` middleware options.
No dependency data recorded yet.