basic auth for dbgate web

This commit is contained in:
Jan Prochazka
2020-06-10 19:58:05 +02:00
parent 235a9ff92d
commit eb7c65dc95
3 changed files with 28 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
const express = require('express');
const basicAuth = require('express-basic-auth');
const bodyParser = require('body-parser');
const http = require('http');
const cors = require('cors');
@@ -29,6 +30,18 @@ function start(argument = null) {
const server = http.createServer(app);
socket.set(io(server));
if (process.env.LOGIN && process.env.PASSWORD) {
app.use(
basicAuth({
users: {
[process.env.LOGIN]: process.env.PASSWORD,
},
challenge: true,
realm: 'DbGate Web App',
})
);
}
app.use(cors());
app.use(bodyParser.json());