parse-community / parse-server

Parse Server for Node.js / Express
https://parseplatform.org
Apache License 2.0
20.91k stars 4.78k forks source link

3.4.1 throws error if using mLab, due to changes to MongoStorageAdapter.performInitialization #5678

Closed ghost closed 5 years ago

ghost commented 5 years ago

Issue Description

When running the latest version of parse-server (3.4.1) an Error is thrown if using a database hosted in mLab, and the application fails to start.

This seems to happen due to a change for MongoStorageAdapter, where the performInitialization method now tries to run the serverStatus MongoDB command.

Since mLab doesn't allow running this command the following Error is thrown:

{ MongoError: not authorized on admin to execute command { serverStatus: 1 }}

Unfortunately it doesn't look like it's possible to re-configure the mLab database to allow this request, making it impossible to run the latest version of parse-server together with it.

Steps to reproduce

  1. Setup a database in mLab OR setup a user in a MongoDB database that does not have the permissions to the run serverStatus command.
  2. Run parse-server 3.4.1.
  3. The error should be thrown shortly after Parse-Server has been initialized.

Expected Results

  1. Successful connection to the MongoDB database.

Actual Outcome

  1. parse-server throws an Error due to missing permissions for the MongoDB database.

Environment Setup

Logs/Trace

{ MongoError: not authorized on admin to execute command { serverStatus: 1, lsid: { id: UUID("7de8356e-0ccc-4383-acd9-ff73151a3c1e") }, $clusterTime: { clusterTime: Timestamp(1560430864, 2), signature: { hash: BinData(0, 5DBD8DCDE92F92F253CC5B530C41476F41792CC5), keyId: 6662117802268164097 } }, $db: "admin" }
    at Connection.<anonymous> (C:\src\plejd\cloud-server\node_modules\mongodb\node_modules\mongodb-core\lib\connection\pool.js:443:61)
    at Connection.emit (events.js:189:13)
    at Connection.EventEmitter.emit (domain.js:441:20)
    at processMessage (C:\src\plejd\cloud-server\node_modules\mongodb\node_modules\mongodb-core\lib\connection\connection.js:364:10)
    at Socket.<anonymous> (C:\src\plejd\cloud-server\node_modules\mongodb\node_modules\mongodb-core\lib\connection\connection.js:533:15)
    at Socket.emit (events.js:189:13)
    at Socket.EventEmitter.emit (domain.js:441:20)
    at addChunk (_stream_readable.js:284:12)
    at readableAddChunk (_stream_readable.js:265:11)
    at Socket.Readable.push (_stream_readable.js:220:10)
  operationTime:
   Timestamp { _bsontype: 'Timestamp', low_: 2, high_: 1560430864 },
  ok: 0,
  errmsg:
   'not authorized on admin to execute command { serverStatus: 1, lsid: { id: UUID("7de8356e-0ccc-4383-acd9-ff73151a3c1e") }, $clusterTime: { clusterTime: Timestamp(1560430864, 2), signature: { hash: BinData(0, 5DBD8DCDE92F92F253CC5B530C41476F41792CC5), keyId: 6662117802268164097 } }, $db: "admin" }',
  code: 13,
  codeName: 'Unauthorized',
  '$clusterTime':
   { clusterTime:
      Timestamp { _bsontype: 'Timestamp', low_: 2, high_: 1560430864 },
     signature: { hash: [Binary], keyId: [Long] } },
  name: 'MongoError',
  [Symbol(mongoErrorContextSymbol)]: {} }
ghost commented 5 years ago

This seems to be related to this PR from 10 days ago:

And to this commit:

acinader commented 5 years ago

@BenniPlejd

In my haste to get out the security fix yesterday, I made the mistake of adding the patch to master instead of to 3.4.0. I'll get 3.4.2 ready now to resolve this, and then we can figure out what to do about #5627.

fmendoza commented 5 years ago

Same issue on a VPS hosted on DO. Glad to hear you identify the issue quickly