Skip to content

Commit 5793cdf

Browse files
simonwalzclaude
andcommitted
fix: basic-auth 3 has no default export, use parse()
basic-auth 3.0.0 (pulled in by 856479b) removed the default export in favour of parse(str). The fleet-server and the webui still called the default export, so their authentication was broken. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Simon Walz <contact@simonwalz.de>
1 parent 2e0ba95 commit 5793cdf

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎fleet-server/server.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import http from 'http';
88
import { WebSocketServer } from 'ws';
99
import { fileURLToPath } from 'url';
1010
import fs from 'fs';
11-
import auth from 'basic-auth';
11+
import { parse as parseBasicAuth } from 'basic-auth';
1212
import Handlebars from 'handlebars';
1313

1414
const locale = process.env.LOCALE || 'de-DE';
@@ -59,7 +59,7 @@ app.set('views', path.join(__dirname, 'views'));
5959
const ADMIN_USER = process.env.FLEET_ADMIN_USER || 'admin';
6060
const ADMIN_PASS = process.env.FLEET_ADMIN_PASS || 'admin';
6161
function requireAuth(req, res, next) {
62-
const creds = auth(req);
62+
const creds = parseBasicAuth(req.headers.authorization ?? '');
6363
if (!creds || creds.name !== ADMIN_USER || creds.pass !== ADMIN_PASS) {
6464
res.set('WWW-Authenticate', 'Basic realm="Fleet"');
6565
return res.status(401).json({ error: 'unauthorized' });

‎webui/app.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: Apache-2.0
22
import express from 'express';
33
import { engine } from 'express-handlebars';
4-
import basicAuth from 'basic-auth';
4+
import { parse as parseBasicAuth } from 'basic-auth';
55
import bodyParser from 'body-parser';
66
import net from 'net';
77
import path from 'path';
@@ -93,7 +93,7 @@ app.set('view engine', 'handlebars');
9393
app.set('views', path.join(__dirname, 'views'));
9494

9595
function auth(req, res, next) {
96-
const user = basicAuth(req);
96+
const user = parseBasicAuth(req.headers.authorization ?? '');
9797

9898
if (!user || user.name !== USER) {
9999
res.set('WWW-Authenticate', 'Basic realm="cuos"');

0 commit comments

Comments
 (0)