Skip to content

Commit 722d907

Browse files
author
Sam Kleinman
committed
edits to privlege modification tutorials
1 parent 6e51609 commit 722d907

File tree

4 files changed

+89
-52
lines changed

4 files changed

+89
-52
lines changed

bin/builddata/htaccess-next.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,22 @@ redirect-path: '/reference/command/cleanupOrphaned'
338338
url-base: '/administration/sharded-clusters'
339339
type: 'redirect'
340340
code: 303
341+
outputs:
342+
- 'manual'
343+
- 'before-v2.4'
344+
---
345+
redirect-path: '/tutorial/define-roles'
346+
url-base: '/administration/security-access-control'
347+
type: 'redirect'
348+
code: 303
349+
outputs:
350+
- 'manual'
351+
- 'before-v2.4'
352+
---
353+
redirect-path: '/tutorial/view-roles'
354+
url-base: '/administration/security-access-control'
355+
type: 'redirect'
356+
code: 303
341357
outputs:
342358
- 'manual'
343359
- 'before-v2.4'

source/tutorial/define-privilege.txt renamed to source/tutorial/define-privilege.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.. renamed as an rst file to prevent this from being published in case
2+
this is a stub. If its not we should remove this as it seems
3+
redundant.
4+
15
==================
26
Define a Privilege
37
==================

source/tutorial/define-roles.txt

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1-
=============
2-
Create a Role
3-
=============
1+
===========================
2+
Define MongoDB Access Roles
3+
===========================
44

55
.. default-domain:: mongodb
66

77
.. todo:: Link 'role' below to the conceptual doc, when written
88

9-
Roles grant users access to MongoDB resources. Create roles to define
10-
access to resources according to your operational needs.
9+
Overview
10+
--------
1111

12-
MongoDB scopes each role to the database in which it is created and
13-
uniquely identifies each role by the pairing of its name and its database.
12+
Roles grant users access to MongoDB resources. By default, MongoDB
13+
provides a number of roles that administrators may use to control
14+
access to a MongoDB system. However, if these roles cannot describe
15+
the proper limited subset of access that a user might require in a
16+
deployment, you can define a unique role to provide these access.
17+
18+
Create new roles to define access to resources according to the
19+
operational needs of a deployment.
20+
21+
MongoDB limits the scope of each role to the database where the role
22+
was created. The combination of database name and name of role
23+
uniquely defines a role in MongoDB.
1424

1525
Prerequisites
1626
-------------
@@ -30,39 +40,37 @@ When creating the role, enter these resource-action pairings in
3040
:ref:`resource documents <resource-document>` in the
3141
:data:`~admin.system.roles.privileges` array.
3242

33-
Identify Privileges from Other Roles
34-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43+
Identify Privileges from Existing Roles
44+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3545

36-
If this role is to include all the privileges of an existing role, then instead
37-
of re-creating those privileges, you can add the existing role to this role.
38-
The contained role provides all its privileges to the new role.
46+
If this role must include *all* the privileges of an existing role,
47+
you can add the existing role to this role, rather than adding
48+
privileges individually. The member role provides all its privileges
49+
to the containing role.
3950

4051
When creating the new role, specify each contained role in its own
4152
document in the :data:`~admin.system.roles.roles` array.
4253

4354
Create the Role
4455
~~~~~~~~~~~~~~~
4556

46-
To create the role, use the :dbcommand:`createRole` command.
47-
48-
.. example::
49-
50-
The following command from the :program:`mongo` shell creates the
51-
``myClusterwideAdmin`` role with privileges defined in four
52-
:ref:`resource documents <resource-document>` and privileges inherited
53-
from the ``read`` role on the ``admin`` database.
54-
55-
.. code-block:: javascript
56-
57-
db.runCommand( { createRole: "myClusterwideAdmin",
58-
privileges: [
59-
{ resource: { cluster: true }, actions: [ "addShard" ] },
60-
{ resource: { db: "config", collection: "" }, actions: [ "find", "update", "insert", "remove" ] },
61-
{ resource: { db: "users", collection: "usersCollection" }, actions: [ "update", "insert", "remove" ] },
62-
{ resource: { db: "", collection: "" }, actions: [ "find" ] }
63-
],
64-
roles: [
65-
{ role: "read", db: "admin" }
66-
],
67-
writeConcern: { w: "majority" , wtimeout: 5000 }
68-
} )
57+
To create the role, use the :dbcommand:`createRole` command. Consider
58+
the following example that creates the ``myClusterwideAdmin`` role
59+
with privileges defined in four :ref:`resource documents
60+
<resource-document>` and privileges inherited from the ``read`` role
61+
on the ``admin`` database.
62+
63+
.. code-block:: javascript
64+
65+
db.runCommand( { createRole: "myClusterwideAdmin",
66+
privileges: [
67+
{ resource: { cluster: true }, actions: [ "addShard" ] },
68+
{ resource: { db: "config", collection: "" }, actions: [ "find", "update", "insert", "remove" ] },
69+
{ resource: { db: "users", collection: "usersCollection" }, actions: [ "update", "insert", "remove" ] },
70+
{ resource: { db: "", collection: "" }, actions: [ "find" ] }
71+
],
72+
roles: [
73+
{ role: "read", db: "admin" }
74+
],
75+
writeConcern: { w: "majority" , wtimeout: 5000 }
76+
} )

source/tutorial/view-roles.txt

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
===================
2-
View Existing Roles
3-
===================
1+
==========================
2+
View Existing Access Roles
3+
==========================
44

55
.. default-domain:: mongodb
66

@@ -9,7 +9,8 @@ MongoDB stores roles in the :data:`admin.system.roles` collection in the
99
granted by a specific role.
1010

1111
To view a role you must have the :authaction:`viewRole` action on the
12-
role's database or be authenticated as a user explicitly granted the role.
12+
role's database or have authenticated as a user explicitly granted the
13+
role.
1314

1415
To view a role, use the :dbcommand:`rolesInfo` command:
1516

@@ -24,18 +25,21 @@ following command from the :program:`mongo` shell:
2425

2526
db.runCommand({ rolesInfo: "readWrite" })
2627

28+
Procedures
29+
----------
30+
2731
View a Role in the Current Database
28-
-----------------------------------
32+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2933

30-
If the role is in the current database, specify the role in quotes, as above and as shown here
31-
for the custom role ``dataEntry``:
34+
If the role is in the current database, you can refer to the role
35+
by name, as for the role ``dataEntry`` on the current database:
3236

33-
.. code-block:: javascript
37+
.. code-block:: javascript
3438

35-
db.runCommand({ rolesInfo: "dataEntry" })
39+
db.runCommand({ rolesInfo: "dataEntry" })
3640

3741
View a Role in a Different Database
38-
-----------------------------------
42+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3943

4044
If the role is in a different database, specify the role as a document.
4145
Use the following form:
@@ -44,22 +48,22 @@ Use the following form:
4448

4549
{ role: "<role name>", db: "<role db>" }
4650

47-
For example, to view the custom ``appWriter`` role in the ``orders``
51+
To view the custom ``appWriter`` role in the ``orders``
4852
database, issue the following command from the :program:`mongo` shell:
4953

5054
.. code-block:: javascript
5155

5256
db.runCommand({ rolesInfo: { role: "appWriter", db: "orders" } })
5357

5458
View Multiple Roles
55-
-------------------
59+
~~~~~~~~~~~~~~~~~~~
5660

5761
To view information for multiple roles, specify each role as a document or
5862
string in an array.
5963

60-
For example, to view the custom ``appWriter`` and ``clientWriter`` roles
61-
in the ``orders`` database and to view the ``dataEntry`` role on the
62-
current database, issue the following command from the :program:`mongo`
64+
To view the custom ``appWriter`` and ``clientWriter`` roles
65+
in the ``orders`` database, as well as the ``dataEntry`` role on the
66+
current database, use the following command from the :program:`mongo`
6367
shell:
6468

6569
.. code-block:: javascript
@@ -70,7 +74,12 @@ shell:
7074
} )
7175

7276
View All Custom Roles
73-
---------------------
77+
~~~~~~~~~~~~~~~~~~~~~
7478

7579
To view the all custom roles, query :ref:`admin.system.roles
76-
<admin-system-roles-collection>` collection directly.
80+
<admin-system-roles-collection>` collection directly, for example:
81+
82+
.. code-block:: javascript
83+
84+
db = db.getSiblingDB('admin')
85+
db.system.roles.find()

0 commit comments

Comments
 (0)