|
| 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()`" |
0 commit comments