Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/http-auth/http-auth-connect
Connect integration for http-auth.
https://github.com/http-auth/http-auth-connect
connect express express-js expressjs http-auth javscript
Last synced: 3 months ago
JSON representation
Connect integration for http-auth.
- Host: GitHub
- URL: https://github.com/http-auth/http-auth-connect
- Owner: http-auth
- License: mit
- Created: 2020-02-02T20:16:34.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-06-16T10:32:53.000Z (8 months ago)
- Last Synced: 2024-11-04T09:48:48.007Z (3 months ago)
- Topics: connect, express, express-js, expressjs, http-auth, javscript
- Language: JavaScript
- Homepage:
- Size: 306 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# http-auth-connect
[Connect](https://github.com/senchalabs/connect) integration with [http-auth](https://github.com/gevorg/http-auth) module.[![build](https://github.com/http-auth/http-auth-connect/workflows/build/badge.svg)](https://github.com/http-auth/http-auth-connect/actions/workflows/build.yml)
## Installation
Via git (or downloaded tarball):
```bash
$ git clone git://github.com/http-auth/http-auth-connect.git
```
Via [npm](http://npmjs.org/):```bash
$ npm install http-auth-connect
```## Usage
```javascript
// Express module.
// eslint-disable-next-line node/no-unpublished-require
const express = require("express");// Authentication module.
// eslint-disable-next-line node/no-unpublished-require
const auth = require("http-auth");
// eslint-disable-next-line node/no-unpublished-require
const authConnect = require("http-auth-connect");const basic = auth.basic({
realm: "Simon Area.",
file: __dirname + "/../data/users.htpasswd" // gevorg:gpass, Sarah:testpass
});// Application setup.
const app = express();
app.use(authConnect(basic));// Setup route.
app.get("/", (req, res) => {
res.send(`Hello from express - ${req.user}!`);
});// Start server.
app.listen(1337, () => {
// Log URL.
console.log("Server running at http://127.0.0.1:1337/");
});
```## Running tests
It uses [mocha](https://mochajs.org/), so just run following command in package directory:
```bash
$ npm test
```## License
The MIT License (MIT)