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 <alexg@balena.io>
This commit is contained in:
Alex Gonzalez 2021-07-27 16:57:20 +00:00
parent 1abd10a129
commit 9e0cbe04c6

View File

@ -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) {