Skip to content

handleUnauthorized serves old mashlib HTML when mashlibModule is configured #143

Description

@melvincarvalho

Bug

When mashlibModule is set in config, unauthenticated requests still get the classic mashlib HTML (referencing /mashlib.min.js and /mash.css) instead of the ES module HTML. This causes 404 errors since the local mashlib files aren't installed.

Cause

In src/auth/middleware.js line 127-129, handleUnauthorized() doesn't check request.mashlibModule:

const html = request.solidosUiEnabled
  ? generateSolidosUiHtml()
  : generateDatabrowserHtml(request.url, request.mashlibCdn ? request.mashlibVersion : null);

It only checks solidosUiEnabled and mashlibCdn, missing the mashlibModule path entirely. The generateModuleDatabrowserHtml function is also not imported.

Fix

Add the import and mashlibModule check:

import { generateDatabrowserHtml, generateModuleDatabrowserHtml, generateSolidosUiHtml } from '../mashlib/index.js';

// In handleUnauthorized:
const html = request.solidosUiEnabled
  ? generateSolidosUiHtml()
  : request.mashlibModule
    ? generateModuleDatabrowserHtml(request.mashlibModule)
    : generateDatabrowserHtml(request.url, request.mashlibCdn ? request.mashlibVersion : null);

Steps to reproduce

  1. Set "mashlibModule": "https://unpkg.com/mashlib-next@0.0.8/mashlib.js" in config
  2. Remove/unset mashlib, mashlibCdn, mashlibVersion
  3. Visit any pod resource without authentication
  4. See old mashlib HTML with 404 errors for /mashlib.min.js and /mash.css

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions