@arthovlabs/liber 0.7.4 → 0.7.6
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/package.json +1 -1
- package/src/daemon/liberd.js +3 -3
package/package.json
CHANGED
package/src/daemon/liberd.js
CHANGED
|
@@ -21,12 +21,12 @@ const unauth = guard.createThrottle();
|
|
|
21
21
|
// A shell that polls without a token used to write one log line per request: 12,239
|
|
22
22
|
// of them in a day. Keep the signal, drop the flood.
|
|
23
23
|
const authFailLog = new Map();
|
|
24
|
-
function logAuthFailure(endpoint, ip) {
|
|
24
|
+
function logAuthFailure(endpoint, ip, ua) {
|
|
25
25
|
const key = endpoint + '|' + ip;
|
|
26
26
|
const now = Date.now();
|
|
27
27
|
const prev = authFailLog.get(key) || { at: 0, count: 0 };
|
|
28
28
|
if (now - prev.at > 60000) {
|
|
29
|
-
logger.warn('SYSTEM', 'AUTH_FAILED', { endpoint, ip, suppressed_since_last: prev.count });
|
|
29
|
+
logger.warn('SYSTEM', 'AUTH_FAILED', { endpoint, ip, ua: String(ua || '').slice(0, 60), suppressed_since_last: prev.count });
|
|
30
30
|
authFailLog.set(key, { at: now, count: 0 });
|
|
31
31
|
} else {
|
|
32
32
|
prev.count += 1;
|
|
@@ -434,7 +434,7 @@ class LiberDaemon {
|
|
|
434
434
|
success: false,
|
|
435
435
|
error: 'Unauthorized. Send Authorization: Bearer <token>. The desktop token lives in .liber/daemon.token; other clients get their own from /clients (scope admin).'
|
|
436
436
|
}));
|
|
437
|
-
logAuthFailure(endpoint, req.socket.remoteAddress);
|
|
437
|
+
logAuthFailure(endpoint, req.socket.remoteAddress, req.headers['user-agent']);
|
|
438
438
|
auth.audit({ client: null, ip: req.socket.remoteAddress, method: req.method, endpoint, decision: 'deny', reason: 'bad token' });
|
|
439
439
|
return;
|
|
440
440
|
}
|