From 9e0cbe04c6d1c533c3e66183eca1d3abfb8c381d Mon Sep 17 00:00:00 2001 From: Alex Gonzalez Date: Tue, 27 Jul 2021 16:57:20 +0000 Subject: [PATCH] api-keys: Remove os variant parameter for authentication check The current code authenticates unmanaged production devices which makes no sense. Unmanaged devices do not need to authenticate with the API. Change-type: patch Signed-off-by: Alex Gonzalez --- src/lib/api-keys.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/lib/api-keys.ts b/src/lib/api-keys.ts index b3f5f348..19b3499d 100644 --- a/src/lib/api-keys.ts +++ b/src/lib/api-keys.ts @@ -125,12 +125,10 @@ export const authMiddleware: AuthorizedRequestHandler = async ( }; try { - const conf = await config.getMany(['localMode', 'unmanaged', 'osVariant']); + const conf = await config.getMany(['localMode', 'unmanaged']); - // we only need to check the API key if a) unmanaged and on a production image, or b) managed and not in local mode - const needsAuth = conf.unmanaged - ? conf.osVariant === 'prod' - : !conf.localMode; + // we only need to check the API key if managed and not in local mode + const needsAuth = !conf.unmanaged && !conf.localMode; // no need to authenticate, shortcut if (!needsAuth) {