Skip to content

Commit 68b2f09

Browse files
author
Kay Kim
committed
DOCS-12244: listDB and collection privileges
1 parent 85c3b28 commit 68b2f09

File tree

5 files changed

+149
-30
lines changed

5 files changed

+149
-30
lines changed

source/includes/extracts-listDatabases-auth.yaml

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,76 @@
11
ref: listDatabases-auth-privileges
2+
content: |
3+
4+
- If ``authorizedDatabases`` is unspecified, and
5+
6+
- If the user has :authaction:`listDatabases` action on the
7+
cluster resource, :dbcommand:`listDatabases` command returns all
8+
databases.
9+
10+
- If the user does not have :authaction:`listDatabases` action on
11+
the cluster:
12+
13+
- **For MongoDB 4.0.6+**, :dbcommand:`listDatabases` command returns
14+
only the databases for which the user has privileges
15+
(including databases for which the user has privileges on
16+
specific collections).
17+
18+
- **For MongoDB 4.0.5**, :dbcommand:`listDatabases` command returns
19+
only the databases for which the user has the
20+
:authaction:`find` action on the database resource (and not
21+
the collection resource).
22+
23+
- If ``authorizedDatabases`` is ``true``,
24+
25+
26+
- **For MongoDB 4.0.6+**, :dbcommand:`listDatabases` command returns
27+
only the databases for which the user has privileges
28+
(including databases for which the user has privileges on
29+
specific collections).
30+
31+
- **For MongoDB 4.0.5**, :dbcommand:`listDatabases` command returns
32+
only the databases for which the user has the :authaction:`find`
33+
action on the database resource (and not the collection
34+
resource).
35+
36+
- If ``authorizedDatabases`` is ``false``, and
37+
38+
- If the user has :authaction:`listDatabases` action on the
39+
cluster, :dbcommand:`listDatabases` command returns all databases
40+
41+
- If the user does not have :authaction:`listDatabases` action on
42+
the cluster, :dbcommand:`listDatabases` command errors with
43+
insufficient permissions.
44+
---
45+
ref: listDatabases-auth-privileges-4.0.6
46+
content: |
47+
48+
- If ``authorizedDatabases`` is unspecified, and
49+
50+
- If the user has :authaction:`listDatabases` action on the
51+
cluster resource, :dbcommand:`listDatabases` command returns all
52+
databases.
53+
54+
- If the user does not have :authaction:`listDatabases` action on
55+
the cluster, :dbcommand:`listDatabases` command returns only the
56+
databases for which the user has privileges (including databases
57+
for which the user has privileges on specific collections).
58+
59+
- If ``authorizedDatabases`` is ``true``, :dbcommand:`listDatabases`
60+
command returns only the databases for which the user has
61+
privileges (including databases for which the user has privileges
62+
on specific collections).
63+
64+
- If ``authorizedDatabases`` is ``false``, and
65+
66+
- If the user has :authaction:`listDatabases` action on the
67+
cluster, :dbcommand:`listDatabases` command returns all databases
68+
69+
- If the user does not have :authaction:`listDatabases` action on
70+
the cluster, :dbcommand:`listDatabases` command errors with
71+
insufficient permissions.
72+
---
73+
ref: listDatabases-auth-privileges-4.0.5
274
content: |
375
476
- If ``authorizedDatabases`` is unspecified, and
@@ -16,7 +88,6 @@ content: |
1688
command returns only the databases for which the user has the
1789
:authaction:`find` action on the database resource (and not the
1890
collection resource).
19-
2091
2192
- If ``authorizedDatabases`` is ``false``, and
2293
@@ -26,7 +97,6 @@ content: |
2697
- If the user does not have :authaction:`listDatabases` action on
2798
the cluster, :dbcommand:`listDatabases` command errors with
2899
insufficient permissions.
29-
30100
---
31101
ref: listDatabases-auth-4.0.0-4.0.4
32102
content: |
@@ -38,11 +108,21 @@ content: |
38108
---
39109
ref: listDatabases-auth-4.0.5
40110
content: |
41-
For MongoDB 4.0.5+:
111+
For MongoDB 4.0.5:
42112
If the user does not have the :authaction:`listDatabases`
43113
privilege action, users can run the :dbcommand:`listDatabases`
44114
command to return a list of databases for which the user has the
45115
:authaction:`find` action privilege if the command is run with
46116
``authorizedDatabases`` option unspecified or set to ``true``.
47-
117+
---
118+
ref: listDatabases-auth-4.0.6
119+
content: |
120+
For MongoDB 4.0.6+:
121+
If the user does not have the :authaction:`listDatabases`
122+
privilege action, users can run the :dbcommand:`listDatabases`
123+
command to return a list of databases for which the user has
124+
privileges (including databases for which the user has privileges
125+
on specific collections) if the command is run with
126+
``authorizedDatabases`` option unspecified or set to ``true``.
127+
48128
...

source/reference/built-in-roles.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,13 @@ Every database includes the following client roles:
6161
- :authaction:`listIndexes`
6262
- :authaction:`listCollections`
6363

64-
.. include:: /includes/extracts/listDatabases-auth-4.0.0-4.0.4.rst
65-
64+
65+
.. include:: /includes/extracts/listDatabases-auth-4.0.6.rst
66+
6667
.. include:: /includes/extracts/listDatabases-auth-4.0.5.rst
6768

69+
.. include:: /includes/extracts/listDatabases-auth-4.0.0-4.0.4.rst
70+
6871
.. authrole:: readWrite
6972

7073
.. include:: /includes/extracts/built-in-roles-read-write.rst

source/reference/command/listDatabases.txt

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,26 +60,48 @@ Behavior
6060

6161
When :doc:`authentication </core/authentication>` is enabled:
6262

63-
- For MongoDB 4.0.5+:
64-
The :dbcommand:`listDatabases` command returns different values
65-
based on the privileges assigned to the user who
66-
executes the command and the ``authorizedDatabases`` command option:
67-
68-
.. include:: /includes/extracts/listDatabases-auth-privileges.rst
69-
70-
- For MongoDB 4.0.0-4.0.4:
71-
The :dbcommand:`listDatabases` command returns different values
72-
based on the privileges assigned to the user who
73-
executes the command.
74-
75-
- If the user has the :authaction:`listDatabases` privilege action
76-
on the cluster, the :dbcommand:`listDatabases` command returns a
77-
list of all existing databases.
78-
79-
- If the user does not have the :authaction:`listDatabases`
80-
privilege action on the cluster, the :dbcommand:`listDatabases`
81-
command only returns a list of databases for which the user has
82-
the :authaction:`find` action.
63+
.. tabs::
64+
65+
tabs:
66+
67+
- id: mongodb-4.0.6
68+
name: "MongoDB 4.0.6+"
69+
content: |
70+
For MongoDB 4.0.6+, the :dbcommand:`listDatabases` command
71+
returns different values based on the privileges assigned to
72+
the user who executes the command and the
73+
``authorizedDatabases`` command option:
74+
75+
.. include:: /includes/extracts/listDatabases-auth-privileges-4.0.6.rst
76+
77+
- id: mongodb-4.0.5
78+
name: "MongoDB 4.0.5"
79+
content: |
80+
81+
For MongoDB 4.0.5, the :dbcommand:`listDatabases` command
82+
returns different values based on the privileges assigned to
83+
the user who executes the command and the
84+
``authorizedDatabases`` command option:
85+
86+
.. include:: /includes/extracts/listDatabases-auth-privileges-4.0.5.rst
87+
88+
- id: mongodb-4.0.4
89+
name: "MongoDB 4.0.0-4.0.4"
90+
content: |
91+
92+
For MongoDB 4.0.0-4.0.4, the :dbcommand:`listDatabases` command
93+
returns different values based on the privileges assigned to
94+
the user who executes the command.
95+
96+
- If the user has the :authaction:`listDatabases` privilege
97+
action on the cluster, the :dbcommand:`listDatabases` command
98+
returns a list of all existing databases.
99+
100+
- If the user does not have the :authaction:`listDatabases`
101+
privilege action on the cluster, the
102+
:dbcommand:`listDatabases` command only returns a list of
103+
databases for which the user has the :authaction:`find`
104+
action.
83105

84106
Examples
85107
--------

source/reference/mongo-shell.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ displays some common help methods and commands:
8484

8585
- Print a list of all databases on the server.
8686

87+
The operation corresponds to the :dbcommand:`listDatabases` command.
88+
If the deployment runs with access control, the operation
89+
returns different values based on user privileges. See
90+
:ref:`listDatabases Behavior <listDatabases-behavior>` for details.
91+
8792
* - ``use <db>``
8893

8994
- Switch current database to ``<db>``. The :binary:`~bin.mongo` shell
@@ -114,6 +119,11 @@ displays some common help methods and commands:
114119

115120
- Print a list of all available databases.
116121

122+
The operation corresponds to the :dbcommand:`listDatabases` command.
123+
If the deployment runs with access control, the operation
124+
returns different values based on user privileges. See
125+
:ref:`listDatabases Behavior <listDatabases-behavior>` for details.
126+
117127
* - ``load()``
118128

119129
- Execute a JavaScript file. See

source/reference/privilege-actions.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ Query and Write Actions
6464
and :dbcommand:`renameCollection` commands and the
6565
:method:`db.collection.renameCollection()` helper method.
6666

67-
.. include:: /includes/extracts/listDatabases-auth-4.0.0-4.0.4.rst
68-
67+
.. include:: /includes/extracts/listDatabases-auth-4.0.6.rst
68+
6969
.. include:: /includes/extracts/listDatabases-auth-4.0.5.rst
7070

71+
.. include:: /includes/extracts/listDatabases-auth-4.0.0-4.0.4.rst
72+
7173
Apply this action to database or collection resources.
7274

7375
.. authaction:: insert
@@ -708,10 +710,12 @@ Diagnostic Actions
708710
User can perform the :dbcommand:`listDatabases` command. Apply this
709711
action to the ``cluster`` resource.
710712

711-
.. include:: /includes/extracts/listDatabases-auth-4.0.0-4.0.4.rst
712-
713+
.. include:: /includes/extracts/listDatabases-auth-4.0.6.rst
714+
713715
.. include:: /includes/extracts/listDatabases-auth-4.0.5.rst
714716

717+
.. include:: /includes/extracts/listDatabases-auth-4.0.0-4.0.4.rst
718+
715719
.. authaction:: listCollections
716720

717721
User can perform the :dbcommand:`listCollections` command. Apply this

0 commit comments

Comments
 (0)