From 4871613c67c228085d61b41640bac3cf4a4f5c79 Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Tue, 9 Feb 2021 10:37:51 -0800 Subject: [PATCH] Add missing authentication failure logging --- lib/cwmp.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/cwmp.ts b/lib/cwmp.ts index 99ca591..e868f0c 100644 --- a/lib/cwmp.ts +++ b/lib/cwmp.ts @@ -79,7 +79,7 @@ async function authenticate( sessionContext.cacheSnapshot, "cwmp.auth" ); - if (!authExpression) return true; + if (authExpression == null) return true; let authentication; @@ -901,6 +901,14 @@ export function onConnection(socket: Socket): void { const sessionContext = currentSessions.get(socket); if (!sessionContext) return; currentSessions.delete(socket); + if (sessionContext.authState !== 2) { + logger.accessError({ + message: "Authentication failure", + sessionContext: sessionContext, + }); + return; + } + const now = Date.now(); const lastActivity = sessionContext.lastActivity;