Skip to content

DOCS-7631: adds showPrivileges to cmds/methods where it was missing #2716

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
14 changes: 14 additions & 0 deletions source/includes/apiargs-dbcommand-connectionStatus-field.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
source:
file: apiargs-dbcommand-rolesInfo-field.yaml
ref: showPrivileges
description: |
Set ``showPrivileges`` to true to instruct
:dbcommand:`connectionStatus` to return the full set of
:doc:`privileges </reference/privilege-actions>` that
currently-authenticated users possess.

By default, this field is ``false``.
operation: connectionStatus
interface: dbcommand
position: 1
...
15 changes: 15 additions & 0 deletions source/includes/apiargs-method-db.getRole-field.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
arg_name: field
interface: method
operation: db.getRole
source:
file: apiargs-dbcommand-rolesInfo-field.yaml
ref: showPrivileges
position: 1
---
arg_name: field
interface: method
operation: db.getRole
source:
file: apiargs-dbcommand-rolesInfo-field.yaml
ref: showBuiltinRoles
...
10 changes: 3 additions & 7 deletions source/includes/apiargs-method-db.getRole-param.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ position: 1
type: string
---
arg_name: param
description: |
If ``true``, returns the role's privileges. Pass this argument as a
document: ``{showPrivileges: true}``.
interface: method
name: showPrivileges
operation: db.getRole
optional: true
source:
file: apiargs-method-db.getUser-param.yaml
ref: args
position: 2
type: document
...
16 changes: 16 additions & 0 deletions source/includes/apiargs-method-db.getUser-field.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
source:
file: apiargs-dbcommand-usersInfo-field.yaml
ref: showPrivileges
arg_name: field
interface: method
operation: db.getUser
position: 1
---
source:
file: apiargs-dbcommand-usersInfo-field.yaml
ref: showCredentials
arg_name: field
interface: method
operation: db.getUser
position: 2
...
10 changes: 10 additions & 0 deletions source/includes/apiargs-method-db.getUser-param.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,14 @@ operation: db.getUser
optional: false
position: 1
type: string
---
arg_name: param
description: |
A document specifying additional arguments.
interface: method
name: args
operation: db.getUser
optional: true
position: 2
type: document
...
35 changes: 34 additions & 1 deletion source/reference/command/connectionStatus.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,22 @@ Definition

.. code-block:: javascript

db.runCommand( { connectionStatus: 1 } )
{ connectionStatus: 1, showPrivileges: <boolean> }

:dbcommand:`connectionStatus` supports the following optional
field:

.. include:: /includes/apiargs/dbcommand-connectionStatus-field.rst

Example
-------

To run :dbcommand:`connectionStatus` use the :method:`db.runCommand()`
method, as in the following:

.. code-block:: javascript

db.runCommand( { connectionStatus: 1, showPrivileges: true } )

Output
------
Expand Down Expand Up @@ -60,6 +75,24 @@ Output
:data:`~connectionStatus.authinfo.authenticatedUserRoles[n].role`
applies.

.. data:: connectionStatus.authInfo.authenticatedUserPrivileges

An array with documents describing the :ref:`actions
</reference/privilege-actions>` granted to the current connection,
grouped by resource.

.. data:: connectionStatus.authInfo.authenticatedUserPrivileges[n].resource

A document describing the database and, if applicable, collection
to which
:data:`connectionStatus.authInfo.authenticatedUserPrivileges[n].actions`
applies.

.. data:: connectionStatus.authInfo.authenticatedUserPrivileges[n].actions

An array listing the privilege actions that
the connection has access to for the specified resource.

.. data:: connectionStatus.ok

The return value for the command. A value of ``1`` indicates
Expand Down
11 changes: 10 additions & 1 deletion source/reference/command/rolesInfo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ Definition
The :dbcommand:`rolesInfo` command can also retrieve all roles
scoped to a database.

The command has the following fields:
To match a single role on the database, use the following form:

.. code-block:: javascript

{
rolesInfo: { role: <name>, db: <db> },
showPrivileges: <Boolean>,
showBuiltinRoles: <Boolean>
}
:dbcommand:`rolesInfo` has the following fields:

.. include:: /includes/apiargs/dbcommand-rolesInfo-field.rst

Expand Down
8 changes: 6 additions & 2 deletions source/reference/method/db.getRole.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ db.getRole()
Definition
----------

.. method:: db.getRole( rolename , showPrivileges )
.. method:: db.getRole(rolename, args)

Returns the roles from which this role inherits privileges. Optionally, the
method can also return all the role's privileges.
Expand All @@ -22,9 +22,13 @@ Definition
command can retrieve information for both :ref:`user-defined roles
<user-defined-roles>` and :ref:`built-in roles <built-in-roles>`.

The :method:`db.getRole()` method takes the following arguments:
The :method:`db.getRole()` method accepts the following parameters:

.. include:: /includes/apiargs/method-db.getRole-param.rst

The ``args`` document supports the following fields:

.. include:: /includes/apiargs/method-db.getRole-field.rst

:method:`db.getRole()` wraps the :dbcommand:`rolesInfo` command.

Expand Down
8 changes: 6 additions & 2 deletions source/reference/method/db.getUser.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@ db.getUser()
Definition
----------

.. method:: db.getUser(username)
.. method:: db.getUser(username, args)

Returns user information for a specified user. Run this method on the
user's database. The user must exist on the database on which the method
runs.

The :method:`db.getUser()` method has the following parameter:
The :method:`db.getUser()` method has the following parameters:

.. include:: /includes/apiargs/method-db.getUser-param.rst

The ``args`` document supports the following fields:

.. include:: /includes/apiargs/method-db.getUser-field.rst

:method:`db.getUser()` wraps the :dbcommand:`usersInfo` command.

Required Access
Expand Down