Skip to content

Commit 0ea41ff

Browse files
rkistnercahofmeyr
andauthored
Further tweaks on MongoDB permissions (#97)
* Further tweak mongodb permissions. * Minor edits --------- Co-authored-by: Conrad Hofmeyr <cahofmeyr@gmail.com>
1 parent 1e1fa85 commit 0ea41ff

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,16 @@ There is also a WYSIWYG editor available in our [Mintlify dashboard](https://das
1212

1313
### Development
1414

15-
Install the [Mintlify CLI](https://www.npmjs.com/package/mintlify) to preview the documentation changes locally. To install, use the following command
16-
17-
```
18-
npm i -g mintlify
19-
```
20-
2115
Run the following command at the root of your documentation (where mint.json is)
2216

2317
```
24-
mintlify dev
18+
npx mintlify dev
2519
```
2620

2721
Regularly check for broken links by running
2822

2923
```
30-
mintlify broken-links
24+
npx mintlify broken-links
3125
```
3226

3327
Navigation (and other global settings) is defined in `mint.json`. Learn more about these in [Mintlify's docs](https://mintlify.com/docs/settings/global).

installation/database-setup.mdx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -356,20 +356,29 @@ replicated collections, additionally add the `dbAdmin` permission:
356356

357357
```
358358
readWrite@<your_database>._powersync_checkpoints
359+
read@<your_database>
359360
dbAdmin@<your_database>
360361
```
361362

362-
If you are replicating from multiple databases in the cluster, you need read permissions on the entire cluster:
363+
If you are replicating from multiple databases in the cluster, you need read permissions on the entire cluster, in addtion to the above:
363364

364365
```
365366
readAnyDatabase@admin
366367
```
367368

368-
### Permissions required - Self-hosted
369+
### Privileges required - Self-hosted / Custom roles
370+
371+
For self-hosted MongoDB, or for creating custom roles on MongoDB Atlas, PowerSync requires the following privileges/granted actions:
369372

370-
For self-hosted MongoDB, PowerSync requires the `find`, `changeStream` and `listCollections` permissions on the database being replicated.
373+
* On the database being replicated: `listCollections`.
374+
* On all collections in the database: `changeStream`.
375+
* This must apply to the entire database, not individual collections, `collection: ""`.
376+
* If replicating from multiple databases, this must apply to the entire cluster, `db: ""`.
377+
* On each collection being replicated: `find`.
378+
* On the `_powersync_checkpoints` collection: `createCollection`, `dropCollection`, `find`, `changeStream`, `insert`, `update`, and `remove`.
379+
* To allow PowerSync to automatically enable [`changeStreamPreAndPostImages`](#post-images) on
380+
replicated collections, additionally add the `collMod` permission on all replicated collections.
371381

372-
PowerSync also requires `createCollection`, `dropCollection`, `insert`, `update`, and `remove` permissions to the `_powersync_checkpoints` collection.
373382

374383
### Post-Images
375384

@@ -381,11 +390,11 @@ PowerSync supports three configuration options for post-images:
381390

382391
1. `post_images: off`: Uses `fullDocument: 'updateLookup'` for backwards compatibility. This was the default for older instances. However, this may lead to consistency issues, so we strongly recommend enabling post-images instead.
383392

384-
2. `post_images: auto_configure` (Default for new instances): Automatically enables the `changeStreamPreAndPostImages` option on collections as needed.
393+
2. `post_images: auto_configure` (Default for new instances): Automatically enables the `changeStreamPreAndPostImages` option on collections as needed. Requires the permissions/privileges mentioned above.
385394

386395
3. `post_images: read_only`: Uses `fullDocument: 'required'` and requires `changeStreamPreAndPostImages: { enabled: true }` to be set on every collection referenced in Sync Rules. Replication will error if this is not configured. This option is ideal when permissions are restricted.
387396

388-
* To manually configure collections for `read_only` mode, run this on each collection:
397+
To manually configure collections for `read_only` mode, run this on each collection:
389398

390399
```js
391400
db.runCommand( {
@@ -394,7 +403,7 @@ db.runCommand( {
394403
} )
395404
```
396405

397-
* You can view which collections have the option enabled using:
406+
You can view which collections have the option enabled using:
398407

399408
```js
400409
db.getCollectionInfos().filter(c => c.options?.changeStreamPreAndPostImages?.enabled)

0 commit comments

Comments
 (0)