Skip to content
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

DOCSP-34316 Update Role Example Descriptions #629

Merged
merged 6 commits into from
Nov 17, 2023
Merged
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
lindseymoore marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed source/images/role-template-no-insert.png
Binary file not shown.
Binary file removed source/images/role-template-read-all-data.png
Binary file not shown.
Binary file added source/images/role-template-read-all.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed source/images/role-template-read-write-all-data.png
Binary file not shown.
Binary file not shown.
59 changes: 33 additions & 26 deletions source/rules/examples.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ the document they can read and write.

This section contains templates that define roles for common scenarios. To apply
a set of permissions to a role, find the scenario that most closely matches your
use case. Update the role's permissions table to match the provided screenshot
or copy and paste the provided template into the collection's :doc:`advanced
use case. Update the Field Permissions, Document Permissions, and/or the role's permissions table
to match the provided screenshot or copy and paste the provided
template into the collection's :doc:`advanced
mode </mongodb/configure-advanced-rules>` configuration. Make sure that you
modify any placeholder values (denoted by ``<angle brackets>``) in the template
to match your needs.
Expand All @@ -150,24 +151,26 @@ The Role Can Read All Fields but Cannot Write
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To allow a role to read any field, set the document-level ``read`` field
to ``true``.
to ``true`` and ``write`` field to ``false``.

.. list-table::
:widths: 50 50

* - .. figure:: /images/role-template-read-all-data.png
* - .. figure:: /images/role-template-read-all.png
:alt: A role with permission to read all document fields
:width: 350px

- .. code-block:: json
:emphasize-lines: 6
:emphasize-lines: 7-8

{
"name": "<Role Name>",
"apply_when": <JSON Expression>,
"apply_when": {<JSON Expression>},
"document_filters": {<JSON Expression>},
"insert": <boolean>,
"delete": <boolean>,
"read": true,
"write": false
}

The Role Can Read & Write All Fields
Expand All @@ -180,16 +183,17 @@ permission, so the role will be able to read all fields.
.. list-table::
:widths: 50 50

* - .. figure:: /images/role-template-read-write-all-data.png
* - .. figure:: /images/role-template-read-and-write-all.png
:alt: A role with permission to read and write all document fields
:width: 350px

- .. code-block:: json
:emphasize-lines: 6
:emphasize-lines: 7

{
"name": "<Role Name>",
"apply_when": <JSON Expression>,
"apply_when": {<JSON Expression>},
"document_filters": {<JSON Expression>},
"insert": <boolean>,
"delete": <boolean>,
"write": true,
Expand All @@ -199,26 +203,28 @@ The Role Can Read All Fields & Write to Specific Fields
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To allow a role to read all fields, set the document-level ``read``
field to ``true``. To specify a field that the role can write to, set
field to ``true`` and the ``write`` field to ``false``. To specify a field that the role can write to, set
the ``write`` field to ``true`` in the field's configuration document,
which is embedded in the ``fields`` document.

.. list-table::
:widths: 50 50

* - .. figure:: /images/role-template-write-specific-fields.png
* - .. figure:: /images/role-template-can-write-some-fields.png
:alt: A role with permission to write to specific fields
:width: 350px

- .. code-block:: json
:emphasize-lines: 6, 8
:emphasize-lines: 7, 8, 10

{
"name": "<Role Name>",
"apply_when": <JSON Expression>,
"apply_when": {<JSON Expression>},
"document_filters": {<JSON Expression>},
"insert": <boolean>,
"delete": <boolean>,
"read": true,
"write": false,
"fields": {
"<Field Name>": { "write": true },
...
Expand All @@ -238,20 +244,17 @@ To prevent the role from inserting new documents, set the document-level
.. list-table::
:widths: 50 50

* - .. figure:: /images/role-template-no-insert.png
* - .. figure:: /images/role-template-cannot-insert-new-docs.png
:alt: A role that lacks permission to insert new documents
:width: 350px

.. figure:: /images/role-template-read-write-all-data.png
:alt: A role with permission to read and write all document fields
:width: 350px

- .. code-block:: json
:emphasize-lines: 4, 6
:emphasize-lines: 5, 7

{
"name": "<Role Name>",
"apply_when": <JSON Expression>,
"apply_when": {<JSON Expression>},
"document_filters": {<JSON Expression>},
"insert": false,
"delete": <boolean>,
"write": true,
Expand All @@ -260,23 +263,27 @@ To prevent the role from inserting new documents, set the document-level
The Role Cannot Write to Specific Fields
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To allow a role to write to any field except for those you specify, set
the corresponding field-level ``write`` fields to ``false`` in the
``fields`` document and set the ``additional_fields.write`` field to
``true``.
To allow a role to write to any field except for those you specify,
set the document-level ``read`` field to ``true``. Set
the corresponding field-level ``write`` fields to ``false`` and
``read`` fields to ``true`` in the
``fields`` document. Lastly, set the ``additional_fields.write`` field to
``true``.

.. list-table::
:widths: 50 50

* - .. figure:: /images/role-template-cannot-write-some-fields.png
* - .. figure:: /images/role-template-cannot-write-to-specific-fields.png
:alt: A role with permission to write to some but not all fields
:width: 350px

- .. code-block:: json
:emphasize-lines: 7, 10-11, 15

{
"name": "<Role Name>",
"apply_when": <JSON Expression>,
"apply_when": {<JSON Expression>},
"document_filters": {<JSON Expression>},
"insert": <boolean>,
"delete": <boolean>,
"read": true,
Expand Down
Loading