Skip to content

Commit 4a2ca63

Browse files
committed
DOCS-12098: Clarify permissions for changestream, new privilege action
1 parent fe6288e commit 4a2ca63

File tree

4 files changed

+44
-16
lines changed

4 files changed

+44
-16
lines changed

source/changeStreams.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,7 @@ collaboration functionality, and notification services.
585585
Access Control
586586
--------------
587587

588-
For deployments enforcing :ref:`authentication` and :ref:`authorization
589-
<authorization>`, applications can only open change streams against
590-
collections they have read access to.
588+
.. include:: /includes/extracts/changestream-access-control-collection.rst
591589

592590
Event Notification
593591
------------------

source/includes/extracts-changestream.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,39 @@ content: |
7878
- The connection to the MongoDB deployment is closed.
7979
8080
- .. include:: /includes/extracts/changestream-remove-shard.rst
81+
---
82+
ref: _changestream-access-control-core
83+
content: |
84+
85+
For deployments enforcing :ref:`authentication <authentication>` and
86+
:ref:`authorization <authorization>`, authenticate as a user
87+
with the :authaction:`changeStream` and :authaction:`find`
88+
privilege actions on the collection against which you want to
89+
open a change stream.
90+
91+
The :authrole:`read` :ref:`built-in role <built-in-roles>` includes
92+
the required privileges to support opening a change stream
93+
against a collection. Any built-in role or
94+
:ref:`user-defined role <user-defined-roles>` that
95+
inherits the :authrole:`read` role can also support opening
96+
change streams against a collection.
97+
98+
Alternatively, use :method:`db.createRole` to create a user-defined
99+
role that grants the :authaction:`changeStream` and :authaction:`find`
100+
privilege actions on the
101+
:ref:`target collection <resource-specific-db-collection>`.
102+
See :ref:`user-defined-roles` for more complete documentation.
103+
104+
To associate a built-in role or user-defined role to an existing user,
105+
use the :method:`db.grantRolesToUser()` or
106+
:method:`db.updateUser()` methods. You can also specify
107+
the role when creating a new user using :method:`db.createUser()`.
108+
109+
---
110+
ref: changestream-access-control-collection
111+
source:
112+
file: extracts-changestream.yaml
113+
ref: _changestream-access-control-core
81114
...
82115

83116

source/reference/method/db.collection.watch.txt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,7 @@ Full Document Lookup of Update Operations
7272
Access Control
7373
--------------
7474

75-
When running with access control, the user must have the
76-
:authaction:`find` and :authaction:`changeStream` privilege actions on
77-
the :ref:`collection resource <resource-document>`. That is, a user must
78-
have a :ref:`role <roles>` that grants the following :ref:`privilege
79-
<privileges>`:
80-
81-
.. code-block:: javascript
82-
83-
{ resource: { db: <dbname>, collection: <collection> }, actions: [ "find", "changeStream" ] }
84-
85-
86-
The built-in :authrole:`read` role provides the appropriate
87-
privileges.
75+
.. include:: /includes/extracts/changestream-access-control-collection.rst
8876

8977
Examples
9078
--------

source/reference/privilege-actions.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,15 @@ Deployment Management Actions
381381
User can perform the :dbcommand:`storageDetails` command. Apply this
382382
action to database or collection resources.
383383

384+
Change Stream Actions
385+
---------------------
386+
387+
.. authaction:: changeStream
388+
389+
User with :authaction:`changeStream` and :authaction:`find` on the
390+
specific collection can open a
391+
:doc:`change stream cursor </changeStreams>` for that resource.
392+
384393
Replication Actions
385394
-------------------
386395

0 commit comments

Comments
 (0)