Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/auth/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { checkAccess, getRequiredMode } from '../wac/checker.js';
import { AccessMode } from '../wac/parser.js';
import * as storage from '../storage/filesystem.js';
import { getEffectiveUrlPath } from '../utils/url.js';
import { generateDatabrowserHtml, generateSolidosUiHtml } from '../mashlib/index.js';
import { generateDatabrowserHtml, generateModuleDatabrowserHtml, generateSolidosUiHtml } from '../mashlib/index.js';

/**
* Check if request is authorized
Expand Down Expand Up @@ -123,10 +123,12 @@ export function handleUnauthorized(request, reply, isAuthenticated, wacAllow, au
// If mashlib is enabled, serve mashlib instead of static error page
// Mashlib has built-in login functionality via panes.runDataBrowser()
if (request.mashlibEnabled) {
// Use SolidOS UI if enabled, otherwise fallback to classic mashlib
// Use SolidOS UI if enabled, ES module if configured, otherwise classic mashlib
const html = request.solidosUiEnabled
? generateSolidosUiHtml()
: generateDatabrowserHtml(request.url, request.mashlibCdn ? request.mashlibVersion : null);
: request.mashlibModule
? generateModuleDatabrowserHtml(request.mashlibModule)
: generateDatabrowserHtml(request.url, request.mashlibCdn ? request.mashlibVersion : null);
Comment on lines +129 to +131

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generateModuleDatabrowserHtml expects a string URL (it calls .replace(/\.js$/, ...)). request.mashlibModule can be a non-string truthy value (e.g., true via JSS_MASHLIB_MODULE=true because env parsing coerces "true" to boolean), which would throw a TypeError here and turn 401/403 into a 500. Consider validating request.mashlibModule is a non-empty string before calling, and/or rejecting invalid config earlier with a clear startup error.

Copilot uses AI. Check for mistakes.
return reply.code(statusCode).type('text/html').send(html);
Comment on lines 125 to 132

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change adds a new HTML response path for unauthenticated requests when mashlibModule is configured, but there doesn't appear to be test coverage asserting which HTML wrapper is served for 401/403 with Accept: text/html. Adding an integration test would help prevent regressions across mashlibModule / mashlibCdn / solidosUi configurations.

Copilot uses AI. Check for mistakes.
}
return reply.code(statusCode).type('text/html').send(getErrorPage(statusCode, isAuthenticated, request));
Expand Down