Skip to content

DOCS-7664, DOCS-7530: updates privilege actions for query and write actions #2733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions source/includes/extracts-privilege-actions-base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ref: _action-list
content: |
The user executing the {{type}} requires either :authaction:`find`
privileges on the {{collection}} collection or the
{{listAction}} privilege action. At a minimum, the
:authrole:`read` :doc:`built-in role </reference/built-in-roles>` provide
the requisite permissions.
...
36 changes: 36 additions & 0 deletions source/includes/extracts-privilege-actions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
ref: actions-listIndexes
inherit:
file: extracts-privilege-actions-base.yaml
ref: _action-list
replacement:
type: "command"
collection: ":data:`system.indexes <<database>.system.indexes>`"
listAction: ":authaction:`listIndexes`"
---
ref: actions-db.collection.getIndexes
inherit:
file: extracts-privilege-actions-base.yaml
ref: _action-list
replacement:
type: "method"
collection: ":data:`system.indexes <<database>.system.indexes>`"
listAction: ":authaction:`listIndexes`"
---
ref: actions-listCollections
inherit:
file: extracts-privilege-actions-base.yaml
ref: _action-list
replacement:
type: "command"
collection: ":data:`system.namespaces <<database>.system.namespaces>`"
listAction: ":authaction:`listCollections`"
---
ref: actions-db.getCollectionNames
inherit:
file: extracts-privilege-actions-base.yaml
ref: _action-list
replacement:
type: "method"
collection: ":data:`system.namespaces <<database>.system.namespaces>`"
listAction: ":authaction:`listCollections`"
...
6 changes: 6 additions & 0 deletions source/reference/command/listCollections.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ Output
The return value for the command. A value of ``1`` indicates
success.

Required Access
---------------

.. include:: /includes/extracts/actions-listCollections.rst


Example
-------

Expand Down
5 changes: 5 additions & 0 deletions source/reference/command/listIndexes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ Definition

.. include:: /includes/apiargs/dbcommand-listIndexes-field.rst

Required Access
---------------

.. include:: /includes/extracts/actions-listIndexes.rst

Output
------

Expand Down
24 changes: 24 additions & 0 deletions source/reference/command/mapReduce.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,30 @@ mapReduce
:start-after: start-out
:end-before: end-out

Required Access
---------------

If your MongoDB deployment enforces authentication, the user executing
the :dbcommand:`mapReduce` command must possess the following
privilege actions:

Map-reduce with ``{out : inline}`` output option:
- :authaction:`find`

Map-reduce with the ``replace`` action when :ref:`outputting to a
collection <mapreduce-out-mtd>`:
- :authaction:`find`,
- :authaction:`insert`,
- :authaction:`replace`

Map-reduce with the ``merge`` or ``reduce`` actions when
:ref:`outputting to a collection <mapreduce-out-mtd>`:
- :authaction:`find`,
- :authaction:`insert`,
- :authaction:`update`

The :authrole:`readWrite` built-in role provides the necessary
permissions to perform map-reduce aggregation.

Map-Reduce Examples
-------------------
Expand Down
5 changes: 5 additions & 0 deletions source/reference/method/db.collection.getIndexes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ Considerations

.. include:: /includes/fact-wiredtiger-compatibility-with-old-shells.rst

Required Access
---------------

.. include:: /includes/extracts/actions-db.collection.getIndexes.rst

Output
------

Expand Down
5 changes: 5 additions & 0 deletions source/reference/method/db.getCollectionNames.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ Considerations

.. include:: /includes/fact-wiredtiger-compatibility-with-old-shells.rst

Required Access
---------------

.. include:: /includes/extracts/actions-db.getCollectionNames.rst

Example
-------

Expand Down
121 changes: 108 additions & 13 deletions source/reference/privilege-actions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,129 @@ Query and Write Actions
-----------------------

.. authaction:: find

User can perform the following commands, and their equivalent helper methods:

- :dbcommand:`aggregate` for all :doc:`pipeline operations
</reference/operator/aggregation>` **except** :pipeline:`$out` and
:pipeline:`$indexStats`.
- :dbcommand:`checkShardingIndex`
- :dbcommand:`count`
- :dbcommand:`dataSize`
- :dbcommand:`distinct`
- :dbcommand:`filemd5`
- :dbcommand:`find`
- :dbcommand:`geoNear`
- :dbcommand:`geoSearch`
- :dbcommand:`getLastError`
- :dbcommand:`getMore`
- :dbcommand:`getPrevError`
- :dbcommand:`group`
- :dbcommand:`killCursors`
- :dbcommand:`listCollections`
- :dbcommand:`listIndexes`
- :dbcommand:`mapReduce` with the ``{out: inline}`` option.
- :dbcommand:`parallelCollectionScan`
- :dbcommand:`repairCursor`
- :dbcommand:`resetError`

Required for the query portion of the :dbcommand:`mapReduce` command and
:method:`db.collection.mapReduce` helper method when :ref:`outputting
to a collection <mapreduce-out-mtd>`.

Required for the query portion of the :dbcommand:`findAndModify` command
and :method:`db.collection.findAndModify` helper method.

User can perform the :method:`db.collection.find()` method. Apply this
action to database or collection resources.
Required on the *source* collection for the :dbcommand:`cloneCollectionAsCapped`
and :dbcommand:`renameCollection` commands and the
:method:`db.collection.renameCollection()` helper method.

Apply this action to database or collection resources.

.. authaction:: insert

User can perform the :dbcommand:`insert` command. Apply this action to
database or collection resources.
User can perform the following commands and their equivalent methods:

- :dbcommand:`insert`
- :dbcommand:`create`

Required for the output portion of the :dbcommand:`mapReduce`
command and :method:`db.collection.mapReduce()` helper method when
:ref:`outputting to a collection <mapreduce-out-mtd>`.

Required for the :dbcommand:`aggregate` command and
:method:`db.collection.aggregate()` helper method when using the
:pipeline:`$out` pipeline operator.

Required for the :dbcommand:`update` and :dbcommand:`findAndModify`
commands and equivalent helper methods when used with the ``upsert``
option.

Required on the *destination* collection for the following
commands and their helper methods:

- :dbcommand:`clone`
- :dbcommand:`cloneCollection`
- :dbcommand:`cloneCollectionAsCapped`
- :dbcommand:`copydb`
- :dbcommand:`renameCollection`

Apply this action to database or collection resources.

.. authaction:: remove

User can perform the :method:`db.collection.remove()` method. Apply this
action to database or collection resources.
User can perform the :dbcommand:`delete` command and equivalent
helper method.

Required for the write portion of the :dbcommand:`findAndModify`
command and :method:`db.collection.findAndModify()` method.

Required for the :dbcommand:`mapReduce` command and
:method:`db.collection.mapReduce()` helper method when you specify
the ``replace`` action when :ref:`outputting to a collection
<mapreduce-out-mtd>`.

Required for the :dbcommand:`aggregate` command and
:method:`db.collection.aggregate()` helper method when using the
:pipeline:`$out` pipeline operator.

Apply this action to database or collection resources.

.. authaction:: update

User can perform the :dbcommand:`update` command. Apply this action to
database or collection resources.
User can perform the :dbcommand:`update` command and equivalent
helper methods.

Required for the
:dbcommand:`mapReduce` command and :method:`db.collection.mapReduce()`
helper method when :ref:`outputting to a collection <mapreduce-out-mtd>`
without specifying the ``replace`` action.

Required for the :dbcommand:`findAndModify` command and
:method:`db.collection.findAndModify()` helper method.

Apply this action to database or collection resources.

.. authaction:: bypassDocumentValidation

.. versionadded:: 3.2

User can bypass document validation on commands that support the
``bypassDocumentValidation`` option. For a list of commands that
support the ``bypassDocumentValidation`` option, see
:ref:`3.2-rel-notes-document-validation`. Apply this action to
database or collection resources.
Users can bypass :doc:`document validation
</core/document-validation>` on commands and methods that support
the ``bypassDocumentValidation`` option. The following commands and
their equivalent methods support bypassing document validation:

- :dbcommand:`aggregate`
- :dbcommand:`applyOps`
- :dbcommand:`cloneCollection` on the *destination* collection
- :dbcommand:`clone` on the *destination*
- :dbcommand:`copydb` on the *destination*
- :dbcommand:`findAndModify`
- :dbcommand:`insert`
- :dbcommand:`mapReduce`
- :dbcommand:`update`

Apply this action to database or collection resources.

Database Management Actions
---------------------------
Expand Down