Skip to content

Commit 3a68366

Browse files
committed
DOCSP-5331: Access Control for creating Views
1 parent 636f003 commit 3a68366

File tree

6 files changed

+123
-33
lines changed

6 files changed

+123
-33
lines changed

source/core/capped-collections.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _manual-capped-collection:
2+
13
==================
24
Capped Collections
35
==================
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
ref: access-control-create-cmd
2+
content: |
3+
4+
If the deployment enforces
5+
:ref:`authentication/authorization <authentication>`,
6+
{{operation}} requires that the authenticated user have the
7+
following privileges:
8+
9+
.. list-table::
10+
:header-rows: 1
11+
12+
* -
13+
14+
- Required Privileges
15+
16+
* - Create a non-capped collection
17+
18+
- :authaction:`createCollection` on the database, **or**
19+
20+
:authaction:`insert` on the collection to create
21+
22+
* - Create a :ref:`capped collection <manual-capped-collection>`
23+
24+
- :authaction:`convertToCapped` for the collection
25+
26+
27+
:authaction:`createCollection` on the database
28+
29+
* - Create a :ref:`view <3.4-reference-views>`
30+
31+
- - :authaction:`createCollection` on the database
32+
33+
*or*
34+
35+
- :authaction:`createCollection` on the database
36+
*and* :authaction:`find` on the source collection/view
37+
38+
*or*
39+
40+
- :authaction:`createCollection` on the database,
41+
:authaction:`find` on the view to create,
42+
*and* :authaction:`find` on the source collection/view
43+
44+
A user with :authaction:`createCollection` on the database and
45+
:authaction:`find` on the view to create does not have
46+
sufficient privileges.
47+
48+
post : |
49+
50+
The :authrole:`readWrite` built in role provides the appropriate
51+
privileges for executing {{operation}}. Create a user and assign it
52+
the :authrole:`readWrite` role for the database in which you want to
53+
run {{operation}}:
54+
55+
.. code-block:: javascript
56+
57+
db.getSiblingDB("replaceThisDatabaseName").createUser(
58+
{
59+
"user" : "replaceThisUserName",
60+
"pwd" : "replaceThisWithASecurePassword",
61+
"roles" : [ "readWrite" ]
62+
}
63+
)
64+
65+
For more examples of user creation, see
66+
:doc:`/tutorial/create-users`. For a tutorial on adding privileges to
67+
an existing database user, see :ref:`modify-existing-user-access`.
68+
replacement:
69+
operation : ":dbcommand:`create`"
70+
---
71+
ref: access-control-createCollection
72+
source:
73+
file: extracts-create-cmd.yaml
74+
ref: access-control-create-cmd
75+
replacement:
76+
operation : ":method:`db.createCollection()`"
77+
---
78+
ref: access-control-createView
79+
content : |
80+
81+
If the deployment enforces
82+
:ref:`authentication/authorization <authentication>`,
83+
the :method:`db.createView()` method requires the authenticated user
84+
have the following privileges:
85+
86+
- :authaction:`createCollection` on the database
87+
88+
*or*
89+
90+
- :authaction:`createCollection` on the database
91+
*and* :authaction:`find` on the source collection/view
92+
93+
*or*
94+
95+
- :authaction:`createCollection` on the database,
96+
:authaction:`find` on the view to create,
97+
*and* :authaction:`find` on the source collection/view
98+
99+
A user with :authaction:`createCollection` on the database
100+
and :authaction:`find` on the view to create does not have sufficient
101+
privileges.
102+
103+
source:
104+
file: extracts-create-cmd.yaml
105+
ref: access-control-create-cmd
106+
replacement:
107+
operation : ":method:`db.createView()`"

source/reference/command/create.txt

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -62,39 +62,7 @@ longer.
6262
Access Control
6363
--------------
6464

65-
If the deployment enforces authentication/authorization, you must have
66-
the following privilege to run the :dbcommand:`create` command:
67-
68-
.. list-table::
69-
:header-rows: 1
70-
71-
* -
72-
73-
- Required Privileges
74-
75-
* - Create a non-capped collection
76-
77-
- :authaction:`createCollection` in the database, **or**
78-
79-
:authaction:`insert` in the collection to create
80-
81-
* - Create a capped collection
82-
83-
- :authaction:`convertToCapped` for the colleciton
84-
85-
86-
:authaction:`createCollection` in the database
87-
88-
* - Create a view
89-
90-
- :authaction:`createCollection` in the database and either:
91-
92-
- no :authaction:`find` on the view to create, **or**
93-
94-
- both :authaction:`find` on the view to create and
95-
:authaction:`find` on the source collection/view.
96-
97-
The built-in role :authrole:`readWrite` provides the required privileges.
65+
.. include:: /includes/extracts/access-control-create-cmd.rst
9866

9967
Examples
10068
--------

source/reference/method/db.createCollection.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ Definition
6161

6262
.. include:: /includes/apiargs/method-db.createCollection-options-param.rst
6363

64+
Access Control
65+
--------------
66+
67+
.. include:: /includes/extracts/access-control-createCollection.rst
68+
69+
6470
Examples
6571
--------
6672

source/reference/method/db.createView.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ Behavior
5959

6060
.. include:: /includes/extracts/views-behavior.rst
6161

62+
Access Control
63+
--------------
64+
65+
.. include:: /includes/extracts/access-control-createView.rst
66+
6267
Examples
6368
--------
6469

source/tutorial/manage-users-and-roles.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ The following example creates a role named
114114

115115
.. include:: /includes/steps/create-role-dropSystemViews.rst
116116

117+
.. _modify-existing-user-access:
118+
117119
Modify Access for an Existing User
118120
----------------------------------
119121

0 commit comments

Comments
 (0)