mirror of
https://github.com/wg-easy/wg-easy.git
synced 2025-10-05 15:47:18 +08:00
bring password hash back
users want to have this instead cleartext password. Mitigates security issues.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const bcrypt = require('bcryptjs');
|
||||
const crypto = require('node:crypto');
|
||||
const { createServer } = require('node:http');
|
||||
const { stat, readFile } = require('node:fs/promises');
|
||||
@@ -117,6 +118,15 @@ module.exports = class Server {
|
||||
return next();
|
||||
}
|
||||
|
||||
if (req.url.startsWith('/api/') && req.headers['authorization']) {
|
||||
if (bcrypt.compareSync(req.headers['authorization'], bcrypt.hashSync(PASSWORD, 10))) {
|
||||
return next();
|
||||
}
|
||||
return res.status(401).json({
|
||||
error: 'Incorrect Password',
|
||||
});
|
||||
}
|
||||
|
||||
return res.status(401).json({
|
||||
error: 'Not Logged In',
|
||||
});
|
||||
|
Reference in New Issue
Block a user