Skip to content

DOCS-2238 add grantRolestoRole method #1416

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

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 8 additions & 0 deletions bin/builddata/htaccess.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3275,4 +3275,12 @@ code: 301
outputs:
- 'master'
- 'manual'
---
redirect-path: '/reference/method/db.grantRolesToRole'
url-base: '/reference/security'
type: 'redirect'
code: 301
outputs:
- 'manual'
- 'before-v2.4'
...
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Only users with access that includes the :authaction:`revokeRole` action on
a database can revoke a role from that database.
a database can revoke a role on that database.
10 changes: 5 additions & 5 deletions source/includes/ref-toc-method-role-management.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
# description: |
# Removes the specified privileges from a user-defined role.
# ---
# name: :method:`db.grantRolesToRole()`
# file: /reference/method/db.grantRolesToRole
# description: |
# Specifies roles from which a user-defined role inherits privileges.
name: :method:`db.grantRolesToRole()`
file: /reference/method/db.grantRolesToRole
description: |
Specifies roles from which a user-defined role inherits privileges.
# ---
# name: :method:`db.revokeRolesFromRole()`
# file: /reference/method/db.revokeRolesFromRole
Expand All @@ -47,4 +47,4 @@
# file: /reference/method/db.getRoles
# description: |
# Returns information for all the user-defined roles in a database.
#...
...
6 changes: 2 additions & 4 deletions source/reference/command/grantRolesToRole.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ Definition

.. dbcommand:: grantRolesToRole

Add additional roles to a :ref:`user-defined <user-defined-roles>`
role.
Grants roles to a :ref:`user-defined role <user-defined-roles>`.

The :dbcommand:`grantRolesToRole` command affects roles on the
database where the command runs. :dbcommand:`grantRolesToRole` has
Expand All @@ -36,8 +35,7 @@ Definition
Required Access
---------------

To grant a role, a user must have access that includes the
:authaction:`grantRole` action on the relevant database.
.. include:: /includes/access-grant-roles.rst

Example
-------
Expand Down
2 changes: 1 addition & 1 deletion source/reference/command/grantRolesToUser.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Definition
Required Access
---------------

.. include:: /includes/access-grant-role-to-user.rst
.. include:: /includes/access-grant-roles.rst

Example
-------
Expand Down
2 changes: 1 addition & 1 deletion source/reference/command/revokeRolesFromUser.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Definition
Required Access
---------------

.. include:: /includes/access-revoke-role-from-user.rst
.. include:: /includes/access-revoke-roles.rst

Example
-------
Expand Down
20 changes: 20 additions & 0 deletions source/reference/method/db.grantRolesToUser-param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
object:
name: db.grantRolesToRole
type: method
field:
optional: false
type: param
name: rolename
type: string
position: 1
description: |
The name of the role to which to grant sub roles.
---
file: /reference/command/grantRolesToRole-field.yaml
name: roles
position: 2
---
file: /reference/command/grantRolesToRole-field.yaml
name: writeConcern
position: 3
...
49 changes: 49 additions & 0 deletions source/reference/method/db.grantRolesToUser.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
=====================
db.grantRolesToRole()
=====================

.. default-domain:: mongodb

Definition
----------

.. method:: db.grantRolesToRole ( rolename, roles, writeConcern )

Grants roles to a :ref:`user-defined role <user-defined-roles>`.

The :method:`grantRolesToRole` method uses the following syntax:

.. code-block:: javascript

db.grantRolesToRole( "<rolename>", [<roles>], {writeConcern} )

The :method:`grantRolesToRole` method takes the following arguments:

.. include:: /reference/method/db.grantRolesToRole-param.rst

.. |local-cmd-name| replace:: :method:`db.grantRolesToRole()`
.. include:: /includes/fact-roles-array-contents.rst

The :method:`db.grantRolesToRole()` method wraps the
:dbcommand:`grantRolesToRole` command.

Required Access
---------------

.. include:: /includes/access-grant-roles.rst

Example
-------

.. TODO Update this example

The following :method:`grantRolesToRole()` operation updates the
``productsReaderWriter`` role to inherit the privileges of
``productsReader``:

.. code-block:: javascript

db.grantRolesToRole( "productsReaderWriter",
[ "productsReader" ],
{ w: "majority" , wtimeout: 5000 }
)
4 changes: 2 additions & 2 deletions source/tutorial/change-user-privileges.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ For an overview of roles and privileges, see :ref:`authorization`.
Prerequisites
-------------

.. include:: /includes/access-grant-role-to-user.rst
.. include:: /includes/access-grant-roles.rst

.. include:: /includes/access-revoke-role-from-user.rst
.. include:: /includes/access-revoke-roles.rst

Procedure
---------
Expand Down