badmfck-api-server 5.0.15 → 5.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +667 -0
- package/dist/apiServer/APIService.d.ts +16 -4
- package/dist/apiServer/APIService.js +92 -3
- package/dist/apiServer/WebSocketServer.d.ts +39 -0
- package/dist/apiServer/WebSocketServer.js +173 -0
- package/dist/apiServer/deployment/Activate.js +1 -1
- package/dist/apiServer/deployment/Backups.js +1 -1
- package/dist/apiServer/deployment/Deploy.js +1 -1
- package/dist/apiServer/deployment/Deployer.js +5 -5
- package/dist/apiServer/deployment/DeployerService.d.ts +12 -0
- package/dist/apiServer/deployment/DeployerService.js +51 -21
- package/dist/apiServer/deployment/HashPassword.d.ts +1 -0
- package/dist/apiServer/deployment/HashPassword.js +91 -0
- package/dist/apiServer/deployment/NginxHelper.d.ts +1 -1
- package/dist/apiServer/deployment/NginxHelper.js +3 -0
- package/dist/apiServer/deployment/Restore.js +1 -1
- package/dist/apiServer/deployment/Status.js +1 -1
- package/dist/apiServer/deployment/cli.js +11 -0
- package/dist/apiServer/deployment/cliCommon.d.ts +1 -0
- package/dist/apiServer/deployment/cliCommon.js +4 -0
- package/dist/apiServer/helper/PasswordHash.d.ts +5 -0
- package/dist/apiServer/helper/PasswordHash.js +52 -0
- package/dist/apiServer/monitor/AccessStore.d.ts +24 -0
- package/dist/apiServer/monitor/AccessStore.js +146 -0
- package/dist/apiServer/monitor/Monitor.js +7 -3
- package/dist/apiServer/monitor/MonitorAuth.d.ts +4 -2
- package/dist/apiServer/monitor/MonitorAuth.js +17 -7
- package/dist/apiServer/monitor/index.html +70 -61
- package/dist/index.d.ts +11 -0
- package/dist/index.js +27 -1
- package/monitoring.help.md +1 -1
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ const crypto_1 = __importDefault(require("crypto"));
|
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const LogService_1 = require("../LogService");
|
|
11
|
+
const PasswordHash_1 = require("../helper/PasswordHash");
|
|
11
12
|
class MonitorAuth {
|
|
12
13
|
static ROLE_CAPS = {
|
|
13
14
|
admin: ["dashboard", "logs", "admin"],
|
|
@@ -128,17 +129,23 @@ class MonitorAuth {
|
|
|
128
129
|
}
|
|
129
130
|
static compliantUsers(users) {
|
|
130
131
|
return users.filter(u => u && typeof u.login === "string" && u.login.length > 0
|
|
131
|
-
&&
|
|
132
|
+
&& PasswordHash_1.PasswordHash.isHash(u.password));
|
|
132
133
|
}
|
|
133
134
|
static policyReportFor(users) {
|
|
134
135
|
const out = [];
|
|
135
136
|
for (const u of users || []) {
|
|
136
|
-
const reason = !u?.login ? "login is empty"
|
|
137
|
+
const reason = !u?.login ? "login is empty"
|
|
138
|
+
: PasswordHash_1.PasswordHash.isHash(u.password) ? null
|
|
139
|
+
: MonitorAuth.PLAINTEXT_ERROR;
|
|
137
140
|
if (reason)
|
|
138
141
|
out.push(`${u?.login || "<no login>"}: ${reason}`);
|
|
139
142
|
}
|
|
140
143
|
return out;
|
|
141
144
|
}
|
|
145
|
+
static PLAINTEXT_ERROR = "password is built incorrectly — the config must hold a hash from `npx badmfck hash-password`, not the password itself";
|
|
146
|
+
static plaintextLogins(users) {
|
|
147
|
+
return (users || []).filter(u => u?.login && !PasswordHash_1.PasswordHash.isHash(u.password)).map(u => u.login);
|
|
148
|
+
}
|
|
142
149
|
static base32Decode(input) {
|
|
143
150
|
const A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
144
151
|
let bits = 0, value = 0;
|
|
@@ -235,7 +242,7 @@ class MonitorAuth {
|
|
|
235
242
|
const x = Buffer.from(String(a), "utf-8"), y = Buffer.from(String(b), "utf-8");
|
|
236
243
|
return x.length === y.length && crypto_1.default.timingSafeEqual(x, y);
|
|
237
244
|
}
|
|
238
|
-
static authenticate(users, login, password, totp) {
|
|
245
|
+
static async authenticate(users, login, password, totp) {
|
|
239
246
|
const locked = MonitorAuth.lockoutRemainingMs(login);
|
|
240
247
|
if (locked > 0)
|
|
241
248
|
return { error: `account locked, try again in ${Math.ceil(locked / 60000)} min` };
|
|
@@ -245,10 +252,13 @@ class MonitorAuth {
|
|
|
245
252
|
MonitorAuth.registerFailure(login);
|
|
246
253
|
return { error: "Invalid user" };
|
|
247
254
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
255
|
+
if (!PasswordHash_1.PasswordHash.isHash(candidate.password)) {
|
|
256
|
+
const matches = typeof candidate.password === "string" && candidate.password.length > 0
|
|
257
|
+
&& MonitorAuth.sameSecret(candidate.password, password || "");
|
|
258
|
+
MonitorAuth.registerFailure(login);
|
|
259
|
+
return { error: matches ? MonitorAuth.PLAINTEXT_ERROR : "Invalid user" };
|
|
260
|
+
}
|
|
261
|
+
if (!(await PasswordHash_1.PasswordHash.verify(password || "", candidate.password))) {
|
|
252
262
|
MonitorAuth.registerFailure(login);
|
|
253
263
|
return { error: "Invalid user" };
|
|
254
264
|
}
|