http-auth-connect provides a specialized middleware adapter that integrates the robust `http-auth` module with the `Connect` framework, thereby extending its utility to widely-used web frameworks like `Express.js`. It enables straightforward implementation of HTTP Basic and Digest authentication within Node.js web applications by wrapping `http-auth` configurations into a `Connect`-compatible middleware function. The current stable version is 1.0.6, with recent updates primarily focused on addressing security audit findings, indicating a maintenance-oriented release cadence rather than active feature development. Its primary differentiator is simplifying the application of `http-auth`'s comprehensive authentication schemes directly within the standard `Connect`/`Express` middleware stack, allowing developers to leverage existing, proven authentication logic without custom integration boilerplate.
npm install http-auth-connectVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up HTTP Basic Authentication using `http-auth-connect` with Express, protecting a simple route. It includes creating a temporary .htpasswd file for user credentials.
Ensure `http-auth` is installed (`npm install http-auth`) and correctly configured according to its documentation before passing its `auth` instance to `http-auth-connect`.
For production, configure `http-auth` to use a custom `verify` function or integrate with a proper user management system. Refer to the `http-auth` documentation for advanced authentication strategies.
Ensure your application uses a Connect-compatible framework (like Express or Connect itself) to integrate this middleware. For other frameworks, a custom adapter might be necessary.
Install the core `http-auth` package: `npm install http-auth`.
Double-check the `file` path for your `.htpasswd` to ensure it's absolute and points to a valid file. Verify the `.htpasswd` file format is correct. Ensure the `realm` option in `auth.basic` configuration is set as intended.
Inspect your `.htpasswd` file for correct username:hashedpassword format. Ensure no extra newlines or invalid characters are present. Use a tool to generate valid Apache-compatible `.htpasswd` entries.