verdaccio / monorepo

🏰 Core dependencies and plugins for verdaccio 5.x branch ⚠️ DEPRECATED
https://verdaccio.org
MIT License
81 stars 62 forks source link

@verdaccio/active-directory plugin : "log.trace is not a function" when npm login #702

Closed gulecroc closed 6 months ago

gulecroc commented 6 months ago

Your Environment

Describe the bug

When login with npm login --registry=https://my-npm-registry.com, the verdaccio container crashes with log :

http <-- 200, user: null(10.42.0.229 via 10.42.0.197), req: 'POST /-/v1/login', bytes: 34/0 
http <-- 404, user: null(10.42.0.229 via 10.42.0.197), req: 'POST /-/v1/login', bytes: 34/150 
info <-- 172.16.110.61 requested 'GET /-/ping' 
http <-- 200, user: null(172.16.110.61), req: 'GET /-/ping', bytes: 0/3 
http <-- 200, user: null(172.16.110.61), req: 'GET /-/ping', bytes: 0/3 
info <-- 172.16.110.61 requested 'GET /-/ping' 
http <-- 200, user: null(172.16.110.61), req: 'GET /-/ping', bytes: 0/3 
http <-- 200, user: null(172.16.110.61), req: 'GET /-/ping', bytes: 0/3 
info <-- 10.42.0.197 requested 'PUT /-/user/org.couchdb.user:guillaume.lecroc' 
http <-- 200, user: null(10.42.0.229 via 10.42.0.197), req: 'PUT /-/user/org.couchdb.user:guillaume.lecroc', bytes: 163/0 
warn --- the plugin method add_user in the auth plugin is deprecated and will be removed in next major release, notify to the plugin author 
warn --- the plugin method add_user in the auth plugin is deprecated and will be removed in next major release, notify to the plugin author 
error--- the user guillaume.lecroc could not being added. Error: bad username/password, access denied 
http <-- 409, user: null(10.42.0.229 via 10.42.0.197), req: 'PUT /-/user/org.couchdb.user:guillaume.lecroc', error: bad username/password, access denied 
info <-- 10.42.0.197 requested 'GET /-/user/org.couchdb.user:guillaume.lecroc?write=true' 
http <-- 200, user: null(10.42.0.229 via 10.42.0.197), req: 'GET /-/user/org.couchdb.user:guillaume.lecroc?write=true', bytes: 0/0 
http <-- 304, user: null(10.42.0.229 via 10.42.0.197), req: 'GET /-/user/org.couchdb.user:guillaume.lecroc?write=true', bytes: 0/0 
info <-- 10.42.0.197 requested 'PUT /-/user/org.couchdb.user:guillaume.lecroc/-rev/undefined' 
fatal--- uncaught exception, please report this
TypeError: log.trace is not a function
    at Client._sendSocket (/usr/local/lib/node_modules/@verdaccio/active-directory/node_modules/ldapjs/lib/client/client.js:1275:7)
    at Client._send (/usr/local/lib/node_modules/@verdaccio/active-directory/node_modules/ldapjs/lib/client/client.js:1156:17)
    at Client.bind (/usr/local/lib/node_modules/@verdaccio/active-directory/node_modules/ldapjs/lib/client/client.js:298:15)
    at Object.bindBypass [as bind] (/usr/local/lib/node_modules/@verdaccio/active-directory/node_modules/ldapjs/lib/client/client.js:930:21)
    at /usr/local/lib/node_modules/@verdaccio/active-directory/node_modules/ldapjs/lib/client/client.js:155:11
    at func (/usr/local/lib/node_modules/@verdaccio/active-directory/node_modules/ldapjs/lib/client/client.js:942:9)
    at Array.<anonymous> (/usr/local/lib/node_modules/@verdaccio/active-directory/node_modules/vasync/lib/vasync.js:209:13)
    at waterfall_impl (/usr/local/lib/node_modules/@verdaccio/active-directory/node_modules/vasync/lib/vasync.js:888:11)
    at pipeline (/usr/local/lib/node_modules/@verdaccio/active-directory/node_modules/vasync/lib/vasync.js:168:10)
    at Object.forEachPipeline (/usr/local/lib/node_modules/@verdaccio/active-directory/node_modules/vasync/lib/vasync.js:213:10) 

To Reproduce

Build a custom image to add the plugin (last version is @verdaccio/active-directory@10.2.1) :

FROM verdaccio/verdaccio:5.29.0

USER root
RUN npm install --global @verdaccio/active-directory
USER $VERDACCIO_USER_UID

Configure authentication in the config.yaml file (I use the chart verdaccio/verdaccio:4.16.0) :

Note : the documentation says to call the plugin activedirectory but I think it's for the old plugin https://github.com/nowhammies/verdaccio-activedirectory

configMap: |
  auth:
    '@verdaccio/active-directory':
      url: 'ldap://my-ad.com:389'
      baseDN: 'dc=local,dc=host'
      domainSuffix: 'local.host'

Then on a node container (node:latest), login to the registry :

npm login --registry=https://my-npm-registry.com

The verdaccio pod crashes with the previous log after setting username and password

Expected behavior

Login successfully

Screenshots, server logs, package manager log

Configuration File (cat ~/.config/verdaccio/config.yaml)

Environment information

Debugging output

Contribute to Verdaccio

juanpicado commented 6 months ago

ref https://github.com/verdaccio/monorepo/pull/703

juanpicado commented 6 months ago

ref https://github.com/verdaccio/monorepo/pull/704