Read user login info from discrete file.

`$DOUGAL_ROOT/etc/users.yaml` to be exact.
This commit is contained in:
D. Berge
2020-10-11 18:21:19 +02:00
parent 324306a77d
commit 2aca34e488
3 changed files with 15 additions and 3 deletions

View File

@@ -4,7 +4,7 @@ const cfg = require('../../../lib/config');
const jwt = require('../../../lib/jwt');
async function authorisedIP (req, res) {
const validIPs = cfg.global.login.ip;
const validIPs = cfg._("global.users.login.ip") || {};
for (const key in validIPs) {
const block = new Netmask(key);
if (block.contains(req.ip)) {
@@ -19,7 +19,7 @@ async function authorisedIP (req, res) {
}
async function authorisedHost (req, res) {
const validHosts = cfg.global.login.host
const validHosts = cfg._("global.users.login.host") || {};
for (const key in validHosts) {
const ip = await dns.promises.resolve(key);
if (ip == req.ip) {

View File

@@ -9,7 +9,7 @@ async function login (req, res, next) {
const hash = crypto
.pbkdf2Sync(password, 'Dougal'+user, 10712, 48, 'sha512')
.toString('base64');
for (const credentials of cfg.global.login.user) {
for (const credentials of cfg._("global.users.login.user") || []) {
if (credentials.name == user && credentials.hash == hash) {
const payload = Object.assign({}, credentials);
delete payload.hash;