perak / extract-mongo-schema

Extract schema from Mongo database, including foreign keys
71 stars 22 forks source link

cant authenticate #30

Open amouratoglou opened 1 year ago

amouratoglou commented 1 year ago

hi! looks promising but was not able to make the connection authenticate:

extract-mongo-schema -d "mongodb://root:rootpassword@localhost:27020/socialTemplates-test?authSource=admin" -o schema.json

returns:


{
  authSource: undefined,
  collectionList: null,
  arrayList: null,
  raw: false,
  limit: 100,
  dontFollowFK: { __ANY__: {} },
  includeSystem: false
}
/Users/agustin/.nvm/versions/node/v16.14.2/lib/node_modules/extract-mongo-schema/node_modules/mongodb/lib/utils.js:698
          throw error;
          ^

MongoError: Authentication failed.
    at MessageStream.messageHandler (/Users/agustin/.nvm/versions/node/v16.14.2/lib/node_modules/extract-mongo-schema/node_modules/mongodb/lib/cmap/connection.js:299:20)
    at MessageStream.emit (node:events:526:28)
    at processIncomingData (/Users/agustin/.nvm/versions/node/v16.14.2/lib/node_modules/extract-mongo-schema/node_modules/mongodb/lib/cmap/message_stream.js:144:12)
    at MessageStream._write (/Users/agustin/.nvm/versions/node/v16.14.2/lib/node_modules/extract-mongo-schema/node_modules/mongodb/lib/cmap/message_stream.js:42:5)
    at writeOrBuffer (node:internal/streams/writable:389:12)
    at _write (node:internal/streams/writable:330:10)
    at MessageStream.Writable.write (node:internal/streams/writable:334:10)
    at Socket.ondata (node:internal/streams/readable:754:22)
    at Socket.emit (node:events:526:28)
    at addChunk (node:internal/streams/readable:315:12) {
  ok: 0,
  code: 18,
  codeName: 'AuthenticationFailed'
}

I can connect using mongosh using the same connection string..same with. my app and other mongodb GUI apps.

thanks!

MrMohebi commented 1 year ago

use this switch

-u, --authSource Database for authentication. Example: "admin".