mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 12:17:08 +00:00
Read user login info from discrete file.
`$DOUGAL_ROOT/etc/users.yaml` to be exact.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user