cayasso / mongo-oplog

Watch mongodb oplog in a simple way
380 stars 91 forks source link

MongoError: command find requires authentication #78

Closed bs-rezve closed 3 years ago

bs-rezve commented 3 years ago

Package version: 2.1.4 Node.js Version: v12.16.1 MongoDb Version: 4.0.6

Created an user from MongoDb atlas and set a custom role that has read access to local database. But still it has throws same error.

MongoError: command find requires authentication
    at queryCallback (...\node_modules\mongodb-core\lib\cursor.js:248:25)
    at ...\node_modules\mongodb-core\lib\connection\pool.js:532:18
    at processTicksAndRejections (internal/process/task_queues.js:79:11) {
  operationTime: Timestamp { _bsontype: 'Timestamp', low_: 2, high_: 1605170209 },
  ok: 0,
  errmsg: 'command find requires authentication',
  code: 13,
  codeName: 'Unauthorized',
  '$clusterTime': {
    clusterTime: Timestamp { _bsontype: 'Timestamp', low_: 2, high_: 1605170209 },
    signature: { hash: [Binary], keyId: [Long] }
  },
  name: 'MongoError',
  [Symbol(mongoErrorContextSymbol)]: {}
}

Also tried with different role. For example: readWriteAnyDatabase, readAnyDatabase etc. but nothing actually worked.

Is it possible to mention actually which role is required to a db user to use this package. Thanks

bs-rezve commented 3 years ago

My bad! Problem was in my code. db role readWriteAnyDatabase is working. I guess if i put read access to only local database that also will work.