verdaccio: Unable to View Packages as an Authenticated User on Versions > 6.0.5

Your environment

  • verdaccio version: v6.1.3
  • node version: v22.13.1
  • package manager: npm: 10.9.2 - /usr/local/bin/npm
  • os: Linux 6.8 Alpine Linux
  • platform: docker
  • reverse proxy: yes

Describe the bug

I am unable to view packages as an authenticated user.

Steps to reproduce

  • Spin up a Docker container using the following configuration file:
services:
  verdaccio:
    image: verdaccio/verdaccio:6.1.3
    container_name: verdaccio
    restart: unless-stopped
    cpus: 1.0
    mem_limit: 1G
    memswap_limit: -1
    ports:
      - "0.0.0.0:4873:4873"
    networks:
      - verdaccio_network
    volumes:
      - ./config.yml:/verdaccio/conf/config.yaml:ro
      - ./htpasswd:/verdaccio/storage/htpasswd:ro
      - verdaccio_data:/verdaccio

networks:
  verdaccio_network:

volumes:
  verdaccio_data:
  • Access the Verdaccio web dashboard.
  • Login
  • Try looking for or searching for any packages

Expected behavior

I should be able to view packages as an authenticated user.

Screenshots, Verdaccio server log, package manager log

verdaccio  | info --- config file  - /verdaccio/conf/config.yaml
verdaccio  | info --- plugin @verdaccio/local-storage successfully loaded (storage)
verdaccio  | info --- using htpasswd file: /verdaccio/storage/htpasswd
verdaccio  | info --- plugin verdaccio-htpasswd successfully loaded (authentication)
verdaccio  | info --- plugin @verdaccio/ui-theme successfully loaded (theme)
verdaccio  | warn --- http address - http://[REDACTED_IP]:4873/ - verdaccio/6.1.3
verdaccio  | info <-- [REDACTED_IP] requested 'GET /'
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /', bytes: 0/0
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /', bytes: 0/525
verdaccio  | info <-- [REDACTED_IP] requested 'GET /-/verdaccio/data/packages'
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/verdaccio/data/packages', bytes: 0/0
verdaccio  | http <-- 304, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/verdaccio/data/packages', bytes: 0/0
verdaccio  | info <-- [REDACTED_IP] requested 'POST /-/verdaccio/sec/login'
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'POST /-/verdaccio/sec/login', bytes: 98/0
verdaccio  | http <-- 200, user: admin([REDACTED_IP] via [REDACTED_IP]), req: 'POST /-/verdaccio/sec/login', bytes: 98/341
verdaccio  | info <-- [REDACTED_IP] requested 'GET /-/verdaccio/data/packages'
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/verdaccio/data/packages', bytes: 0/0
verdaccio  | http <-- 304, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/verdaccio/data/packages', bytes: 0/0
verdaccio  | info <-- [REDACTED_IP] requested 'GET /'
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /', bytes: 0/0
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /', bytes: 0/525
verdaccio  | info <-- [REDACTED_IP] requested 'GET /-/verdaccio/data/packages'
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/verdaccio/data/packages', bytes: 0/0
verdaccio  | http <-- 304, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/verdaccio/data/packages', bytes: 0/0
verdaccio  | info <-- [REDACTED_IP] requested 'GET /-/verdaccio/data/search/form'
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/verdaccio/data/search/form', bytes: 0/0
verdaccio  | http <-- 304, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/verdaccio/data/search/form', bytes: 0/0

Configuration file

storage: /verdaccio/storage/data

plugins: /verdaccio/plugins

web:
  login: true

auth:
  htpasswd:
    file: /verdaccio/storage/htpasswd
    max_users: -1

packages:
  "@*/*":
    access: $authenticated
    publish: $authenticated
    unpublish: $authenticated

  "**":
    access: $authenticated
    publish: $authenticated
    unpublish: $authenticated

Contribute to Verdaccio

  • I’m willing to fix this bug 🥇

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 2
  • Comments: 16 (4 by maintainers)

Most upvoted comments

TLDR

It’s a regression of #5090 in src/api/web/index.ts

AI to the rescue

I extracted the diff between 6.0.5 and 6.1.4 and asked Cursor + Claude 4 Sonnet to deep dive into it. Here’s the result after 45 sec of thinking and about 1 min of further analysis.

@juanpicado not sure how much of https://github.com/verdaccio/verdaccio/blob/556bc9747bfd8e8bf31e84852d4cc0fc89f6ce78/src/api/web/index.ts you want to revert but at least we have the root cause identified 😀

My prompt

The diff introduced a new issue: the authentication isn’t working properly anymore. when a logged in user tries to select packages, the user isn’t passed on to the get request. the use id appears as “null” in the http log.

Do a deep dive into the diff to identify what introduced this issue. You can read any other file of the repo if this helps.

Claude’s answer

Based on my deep analysis of the diff, I’ve identified the root cause of the authentication issue. Here’s what happened:

The Problem

The authentication issue was introduced by a critical change in middleware setup in the web interface. Let me break down the specific changes:

Before the diff (working):

// Old setup in src/api/web/index.ts
router.use(auth.webUIJWTmiddleware());  // ← Applied JWT middleware directly
router.use(setSecurityWebHeaders);
router.use('/', renderWebMiddleware(config, null, pluginOptions));  // ← null token middleware
router.use(webEndpointsApi(auth, storage, config));  // ← Web API endpoints

After the diff (broken):

// New setup in src/api/web/index.ts  
router.use('/', renderWebMiddleware(config, auth.apiJWTmiddleware(), pluginOptions));  // ← Changed!
router.use(localWebEndpointsApi(auth, storage, config));

Root Cause Analysis

  1. Middleware Replacement: The diff replaced webUIJWTmiddleware() with apiJWTmiddleware() and moved it inside the renderWebMiddleware call.

  2. Different Middleware Behaviors:

    • webUIJWTmiddleware() is designed for browser-based web UI requests (handles web sessions, cookies, etc.)
    • apiJWTmiddleware() is designed for API calls (handles Bearer tokens, basic auth, etc.)
  3. Authentication Flow Mismatch: Web browsers typically send session cookies or web-specific tokens, but the API middleware expects different authentication methods.

  4. User Context Lost: When the web interface makes requests to get packages, the req.remote_user is null because the API middleware isn’t properly processing the web authentication tokens that browsers send.

The Specific Issue

In packages/web/src/api/package.ts, there’s this logic:

const checkAllow = (name: string, remoteUser: RemoteUser): Promise<boolean> => {
  // ...
  const remoteUserAccess = !isLoginEnabled ? anonymousRemoteUser : remoteUser;
  // If remoteUser is null due to middleware mismatch, authentication fails
}

When remoteUser is null (due to the middleware not properly extracting the user from web requests), the authentication check fails even though the user is logged in.

The Fix

The issue should be resolved by reverting to use webUIJWTmiddleware() for web interface requests instead of apiJWTmiddleware(), or ensuring that the API middleware can properly handle web authentication tokens.

The change essentially broke the separation between web UI authentication (for browsers) and API authentication (for programmatic access), causing logged-in web users to appear as null in the system.

Conclusion

Amazing. The agent certainly could have proposed a PR, too. Crazy times.

@mbtools I already did 😉

services:
  verdaccio:
    image: verdaccio/verdaccio:6.1.4
    container_name: verdaccio
    restart: unless-stopped
    cpus: 1.0
    mem_limit: 1G
    memswap_limit: -1
    ports:
      - "0.0.0.0:4873:4873"
    networks:
      - verdaccio_network
    volumes:
      - ./config.yml:/verdaccio/conf/config.yaml:ro
      - ./htpasswd:/verdaccio/storage/htpasswd:ro
      - verdaccio_data:/verdaccio

networks:
  verdaccio_network:

volumes:
  verdaccio_data:

Confirmation:

sudo docker exec -it verdaccio sh
verdaccio --version
v6.1.4

@mbtools The secret is 32 characters long.

@juanpicado using verdaccio/verdaccio:nightly-master fixes the issue! But I am sure using that version in production is not a good idea 😅

verdaccio  | info --- using config file: /verdaccio/conf/config.yaml
verdaccio  | info -=- local storage path: /verdaccio/storage/data/.verdaccio-db.json
verdaccio  | info -=- plugin @verdaccio/local-storage successfully loaded (storage)
verdaccio  | debug--- plugins folder defined, loading plugins from /verdaccio/plugins
verdaccio  | info --- using htpasswd file: /verdaccio/storage/htpasswd
verdaccio  | info --- plugin verdaccio-htpasswd successfully loaded (authentication)
verdaccio  | info --- plugin verdaccio-audit successfully loaded (middleware)
verdaccio  | info --- plugin @verdaccio/ui-theme successfully loaded (theme)
verdaccio  | info --- http address: http://[REDACTED_IP]:4873/
verdaccio  | info --- version: 8.0.0-next-8.17
verdaccio  | info --- log level: trace
verdaccio  | info --- server started
verdaccio  | info <-- [REDACTED_IP] requested 'POST /-/verdaccio/sec/login'
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'POST /-/verdaccio/sec/login', bytes: 98/0
verdaccio  | http <-- 200, user: admin([REDACTED_IP] via [REDACTED_IP]), req: 'POST /-/verdaccio/sec/login', bytes: 98/341
verdaccio  | info <-- [REDACTED_IP] requested 'GET /-/verdaccio/data/packages'
verdaccio  | http <-- 200, user: admin([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/verdaccio/data/packages', bytes: 0/0
verdaccio  | trace--- [auth/allow_action]: user: admin
verdaccio  | trace--- [auth/allow_action]: hasPermission? true for user: admin, package: @abdelfattahradwan/form-data-utilities
verdaccio  | trace--- auth/allow_action: access granted to: admin
verdaccio  | trace--- [auth/allow_action]: user: admin
verdaccio  | trace--- [auth/allow_action]: hasPermission? true for user: admin, package: @abdelfattahradwan/node-auth-utilities
verdaccio  | trace--- auth/allow_action: access granted to: admin
verdaccio  | http <-- 304, user: admin([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/verdaccio/data/packages', bytes: 0/0

No, it is not good idea as you says, but help for guidance, only suggested as comparison purposes.

@abdelfattahradwan I’d suggest dive debugging in your side, here how to https://github.com/verdaccio/verdaccio/wiki/Debugging-Verdaccio#with-docker

Should I do everything, or is DEBUG='verdaccio*' sufficient?

yes, it would be verbose but as you you get familiar with the package namespaces you can filter out more and more. The debug intend to be very descriptive (no sensitive data is printed or at least would not be intentional) so you can understand better what might be going on.

I see you are using docker, whenever someone use docker and packages are not visible is due permissions since you are mapping

    volumes:
      - ./config.yml:/verdaccio/conf/config.yaml:ro
      - ./htpasswd:/verdaccio/storage/htpasswd:ro
      - verdaccio_data:/verdaccio

So I’d focus on the local storage debug.

I added to my docker-compose.yml file:

environment:
  - DEBUG="verdaccio*"

I also updated my config file:

storage: /verdaccio/storage/data

plugins: /verdaccio/plugins

web:
  html_cache: false

auth:
  htpasswd:
    file: /verdaccio/storage/htpasswd
    max_users: -1

packages:
  "@*/*":
    access: $authenticated
    publish: $authenticated
    unpublish: $authenticated

  "**":
    access: $authenticated
    publish: $authenticated
    unpublish: $authenticated

log: { type: stdout, format: pretty, level: trace }

And recreated the container. I now get the following logs:

verdaccio  | info --- config file  - /verdaccio/conf/config.yaml
verdaccio  | info --- plugin @verdaccio/local-storage successfully loaded (storage)
verdaccio  | debug--- plugins folder defined, loading plugins from /verdaccio/plugins
verdaccio  | info --- using htpasswd file: /verdaccio/storage/htpasswd
verdaccio  | info --- plugin verdaccio-htpasswd successfully loaded (authentication)
verdaccio  | info --- plugin @verdaccio/ui-theme successfully loaded (theme)
verdaccio  | warn --- http address - http://[REDACTED_IP]:4873/ - verdaccio/6.1.3
verdaccio  | info <-- [REDACTED_IP] requested 'GET /'
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /', bytes: 0/0
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /', bytes: 0/525
verdaccio  | info <-- [REDACTED_IP] requested 'GET /-/static/runtime.991e3bf01dfa60ac3987.js'
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/static/runtime.991e3bf01dfa60ac3987.js', bytes: 0/0
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/static/runtime.991e3bf01dfa60ac3987.js', bytes: 0/1943
verdaccio  | info <-- [REDACTED_IP] requested 'GET /-/static/main.991e3bf01dfa60ac3987.js'
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/static/main.991e3bf01dfa60ac3987.js', bytes: 0/0
verdaccio  | info <-- [REDACTED_IP] requested 'GET /-/static/vendors.991e3bf01dfa60ac3987.js'
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/static/vendors.991e3bf01dfa60ac3987.js', bytes: 0/0
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/static/main.991e3bf01dfa60ac3987.js', bytes: 0/88027
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/static/vendors.991e3bf01dfa60ac3987.js', bytes: 0/705958
verdaccio  | info <-- [REDACTED_IP] requested 'GET /-/static/Home.991e3bf01dfa60ac3987.js'
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/static/Home.991e3bf01dfa60ac3987.js', bytes: 0/0
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/static/Home.991e3bf01dfa60ac3987.js', bytes: 0/887
verdaccio  | info <-- [REDACTED_IP] requested 'GET /-/verdaccio/data/packages'
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/verdaccio/data/packages', bytes: 0/0
verdaccio  | trace--- [auth/allow_action]: user: undefined
verdaccio  | trace--- [auth/allow_action]: hasPermission? false for user: undefined, package: @abdelfattahradwan/form-data-utilities
verdaccio  | trace--- [auth/allow_action]: user: undefined
verdaccio  | trace--- [auth/allow_action]: hasPermission? false for user: undefined, package: @abdelfattahradwan/node-auth-utilities
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/verdaccio/data/packages', bytes: 0/3
verdaccio  | info <-- [REDACTED_IP] requested 'POST /-/verdaccio/sec/login'
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'POST /-/verdaccio/sec/login', bytes: 98/0
verdaccio  | http <-- 200, user: admin([REDACTED_IP] via [REDACTED_IP]), req: 'POST /-/verdaccio/sec/login', bytes: 98/341
verdaccio  | info <-- [REDACTED_IP] requested 'GET /-/verdaccio/data/packages'
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/verdaccio/data/packages', bytes: 0/0
verdaccio  | trace--- [auth/allow_action]: user: undefined
verdaccio  | trace--- [auth/allow_action]: hasPermission? false for user: undefined, package: @abdelfattahradwan/form-data-utilities
verdaccio  | trace--- [auth/allow_action]: user: undefined
verdaccio  | trace--- [auth/allow_action]: hasPermission? false for user: undefined, package: @abdelfattahradwan/node-auth-utilities
verdaccio  | http <-- 200, user: null([REDACTED_IP] via [REDACTED_IP]), req: 'GET /-/verdaccio/data/packages', bytes: 0/3

I don’t have any issues with file permissions (thankfully). That’s confirmed when I switch back to an older Verdaccio version and things work.