Skip to content

toc infrastructure for users and roles #1403

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 2 commits 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
4 changes: 4 additions & 0 deletions source/includes/access-user-info.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Users must have the :authaction:`viewUser` action on another users database
to view that user's credentials.

Users can view their own information.
50 changes: 50 additions & 0 deletions source/includes/ref-toc-method-role-management.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: :method:`db.createRole()`
file: /reference/method/db.createRole
description: |
Creates a role and specifies its privileges.
---
name: :method:`db.updateRole()`
file: /reference/method/db.updateRole
description: |
Updates a user-defined role.
---
name: :method:`db.dropRole()`
file: /reference/method/db.dropRole
description: |
Deletes a user-defined role.
---
name: :method:`db.dropAllRoles()`
file: /reference/method/db.dropAllRoles
description: |
Deletes all user-defined roles associated with a database.
---
name: :method:`db.grantPrivilegesToRole()`
file: /reference/method/db.grantPrivilegesToRole
description: |
Assigns privileges to a user-defined role.
---
name: :method:`db.revokePrivilegesFromRole()`
file: /reference/method/db.revokePrivilegesFromRole
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.revokeRolesFromRole()`
file: /reference/method/db.revokeRolesFromRole
description: |
Removes a role from a user.
---
name: :method:`db.getRole()`
file: /reference/method/db.getRole
description: |
Returns information for the specified role.
---
name: :method:`db.getRoles()`
file: /reference/method/db.getRoles
description: |
Returns information for all the user-defined roles in a database.
...
40 changes: 40 additions & 0 deletions source/includes/ref-toc-method-user-management.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: :method:`db.createUser()`
file: /reference/method/db.createUser
description: |
Creates a new user.
---
name: :method:`db.updateUser()`
file: /reference/method/db.updateUser
description: |
Updates user data.
---
name: :method:`db.dropUser()`
file: /reference/method/db.dropUser
description: |
Removes a single user.
---
name: :method:`db.dropAllUsers()`
file: /reference/method/db.dropAllUsers
description: |
Deletes all users associated with a database.
---
name: :method:`db.grantRolesToUser()`
file: /reference/method/db.grantRolesToUser
description: |
Grants a role and its privileges to a user.
---
name: :method:`db.revokeRolesFromUser()`
file: /reference/method/db.revokeRolesFromUser
description: |
Removes a role from a user.
---
name: :method:`db.getUser()`
file: /reference/method/db.getUser
description: |
Returns information about the specified user.
---
name: :method:`db.getUsers()`
file: /reference/method/db.getUsers
description: |
Returns information about all users associated with a database.
...
32 changes: 32 additions & 0 deletions source/reference/method.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,38 @@ Database

/reference/method/js-database

.. _user-management-methods:

User Management
---------------

.. only:: website

.. include:: /includes/toc/table-method-user-management.rst

.. class:: hidden

.. toctree::
:titlesonly:

/reference/method/js-user-management

.. _role-management-methods:

Role Management
---------------

.. only:: website

.. include:: /includes/toc/table-method-role-management.rst

.. class:: hidden

.. toctree::
:titlesonly:

/reference/method/js-role-management

.. _replica-set-functions:

Replication
Expand Down
12 changes: 12 additions & 0 deletions source/reference/method/db.getUser-param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
object:
name: db.getUser()
type: method
field:
optional: false
type: param
name: username
type: string
position: 1
description: |
The name of the user for which to retrieve information.
...
36 changes: 36 additions & 0 deletions source/reference/method/db.getUser.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
============
db.getUser()
============

.. default-domain:: mongodb

Definition
----------

.. method:: db.getUser(username)

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:

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

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

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

.. include:: /includes/access-user-info.rst

Example
-------

The following sequence of operations returns information about the
``appClient`` user on the ``accounts`` database:

.. code-block:: javascript

use accounts
db.getUser("appClient")
19 changes: 19 additions & 0 deletions source/reference/method/db.getUsers.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
=============
db.getUsers()
=============

.. default-domain:: mongodb

Definition
----------

.. method:: db.getUsers()

Returns information for all the users in the database.

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

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

.. include:: /includes/access-user-info.rst
9 changes: 9 additions & 0 deletions source/reference/method/js-role-management.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
=======================
Role Management Methods
=======================

.. default-domain:: mongodb

.. include:: /includes/toc/table-method-role-management.rst

.. include:: /includes/toc/method-role-management.rst
9 changes: 9 additions & 0 deletions source/reference/method/js-user-management.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
=======================
User Management Methods
=======================

.. default-domain:: mongodb

.. include:: /includes/toc/table-method-user-management.rst

.. include:: /includes/toc/method-user-management.rst