From 65a238578e34aa7b3d954935e4b24687c96cc024 Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Thu, 4 Feb 2021 17:34:58 +0000 Subject: [PATCH] add authentication --- app.js | 7 +++++++ package-lock.json | 16 ++++++++++++++++ package.json | 1 + 3 files changed, 24 insertions(+) diff --git a/app.js b/app.js index 8c62345..2f825e3 100644 --- a/app.js +++ b/app.js @@ -2,6 +2,7 @@ const got = require('got') fs = require('fs'); var tableify = require('tableify'); const express = require('express') +const basicAuth = require('express-basic-auth') const app = express() const port = 6969 @@ -65,6 +66,12 @@ function arrayToTable(array) { async function server() { + app.use(basicAuth({ + users: { 'BBLBTV': 'BBLBTV' }, + challenge: true, + realm: 'foo', + })) + app.get('/', async (req, res) => { let t = await main(url) let html = await arrayToTable(t) diff --git a/package-lock.json b/package-lock.json index 9497ea9..167880e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -68,6 +68,14 @@ "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" }, + "basic-auth": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", + "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", + "requires": { + "safe-buffer": "5.1.2" + } + }, "body-parser": { "version": "1.19.0", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", @@ -243,6 +251,14 @@ "vary": "~1.1.2" } }, + "express-basic-auth": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/express-basic-auth/-/express-basic-auth-1.2.0.tgz", + "integrity": "sha512-iJ0h1Gk6fZRrFmO7tP9nIbxwNgCUJASfNj5fb0Hy15lGtbqqsxpt7609+wq+0XlByZjXmC/rslWQtnuSTVRIcg==", + "requires": { + "basic-auth": "^2.0.1" + } + }, "finalhandler": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", diff --git a/package.json b/package.json index a9988de..3fea1d3 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "license": "ISC", "dependencies": { "express": "^4.17.1", + "express-basic-auth": "^1.2.0", "fs": "0.0.1-security", "got": "^11.8.1", "http": "0.0.1-security",