-
Notifications
You must be signed in to change notification settings - Fork 1.7k
DOCS-2480 authorization 2.6 concepts doc #1513
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
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
.. _authorization: | ||
|
||
============= | ||
Authorization | ||
============= | ||
|
||
.. default-domain:: mongodb | ||
|
||
MongoDB employs Role-Based Access Control (RBAC) to govern access to a | ||
MongoDB system. A user is granted one or more :ref:`roles <roles>` that | ||
determine the user's access to database resources and operations. Outside | ||
of role assignments, the user has no access to the system. | ||
|
||
MongoDB provides :doc:`built-in roles </reference/built-in-roles>`, each | ||
with a dedicated purpose for a common use case. Examples include the | ||
:authrole:`read`, :authrole:`readWrite`, :authrole:`dbAdmin`, and | ||
:authrole:`root` roles. | ||
|
||
Administrators also can create new roles and privileges to cater to | ||
operational needs. Administrator can assign privileges scoped as | ||
granularly as the collection level. | ||
|
||
When granted a role, a user receives all the privileges of that role. A | ||
user can have several roles concurrently, in which case the user receives | ||
the union of all the privileges of the respective roles. | ||
|
||
.. _roles: | ||
|
||
Roles | ||
----- | ||
|
||
A role consists of privileges that pair resources with allowed operations. | ||
Each privilege is defined directly in the role or inherited from another | ||
role. | ||
|
||
A role's privileges apply to the database where the role is created. A role | ||
created on the ``admin`` database can include privileges that apply to all | ||
databases or to the :ref:`cluster <resource-cluster>`. | ||
|
||
A user assigned a role receives all the privileges of that role. The user can | ||
have multiple roles and can have different roles on different databases. | ||
|
||
Roles always grant privileges and never limit access. For example, if a user | ||
has both :authrole:`read` *and* :authrole:`readWriteAnyDatabase` roles on a | ||
database, the greater access prevails. | ||
|
||
.. _privileges: | ||
|
||
Privileges | ||
~~~~~~~~~~ | ||
|
||
A privilege consists of a specified resource and the actions permitted on the | ||
resource. | ||
|
||
A privilege :doc:`resource </reference/resource-document>` is either a | ||
database, collection, set of collections, or the cluster. If the cluster, the | ||
affiliated actions affect the state of the system rather than a specific | ||
database or collection. | ||
|
||
An :doc:`action </reference/privilege-actions>` is a command or method the | ||
user is allowed to perform on the resource. A resource can have multiple | ||
allowed actions. For available actions see | ||
:doc:`/reference/privilege-actions`. | ||
|
||
For example, a privilege that includes the :authaction:`update` action | ||
allows a user to modify existing documents on the resource. To | ||
additionally grant the user permission to create documents on the | ||
resource, the administrator would add the :authaction:`insert` action to | ||
the privilege. | ||
|
||
For privilege syntax, see :data:`admin.system.roles.privileges`. | ||
|
||
.. _inheritance: | ||
|
||
Inherited Privileges | ||
~~~~~~~~~~~~~~~~~~~~ | ||
|
||
A role can include one or more existing roles in its definition, in which case | ||
the role inherits all the privileges of the included roles. | ||
|
||
A role can inherit privileges from other roles in its database. A role created | ||
on the ``admin`` database can inherit privileges from roles in any database. | ||
|
||
.. _user-defined-roles: | ||
|
||
User-Defined Roles | ||
~~~~~~~~~~~~~~~~~~ | ||
|
||
.. versionadded:: 2.5.4 | ||
|
||
User administrators can create custom roles to ensure collection-level and | ||
command-level granularity and to adhere to the policy of :term:`least | ||
privilege`. Administrators create and edit roles using the :ref:`role | ||
management commands <role-management-commands>`. | ||
|
||
MongoDB scopes a user-defined role to the database in which it is created and | ||
uniquely identifies the role by the pairing of its name and its database. | ||
MongoDB stores the roles in the ``admin`` database's :doc:`system.roles | ||
</reference/system-roles-collection>` collection. Do not access this | ||
collection directly but instead use the :ref:`role management commands | ||
<role-management-commands>` to view and edit custom roles. | ||
|
||
Role Assignment to Users | ||
------------------------ | ||
|
||
User administrators create the users that access the system's databases. | ||
MongoDB's :ref:`user management commands <user-management-commands>` let | ||
administrators create users and assign them roles. | ||
|
||
MongoDB scopes a user to the database in which the user is created. MongoDB | ||
stores all user definitions in the ``admin`` database, no matter which | ||
database the user is scoped to. MongoDB stores users in the ``admin`` | ||
database's :doc:`system.users collection | ||
</reference/system-users-collection>`. Do not access this collection directly | ||
but instead use the :ref:`user management commands | ||
<user-management-commands>`. | ||
|
||
The first role assigned in a database should be either :authrole:`userAdmin` | ||
or :authrole:`userAdminAnyDatabase`. This user can then create all other users | ||
in the system. See :doc:`/tutorial/add-user-administrator`. | ||
|
||
See Also | ||
-------- | ||
|
||
:doc:`/reference/built-in-roles` | ||
|
||
:doc:`/reference/resource-document` | ||
|
||
:doc:`/reference/privilege-actions` | ||
|
||
:doc:`/tutorial/add-user-administrator` | ||
|
||
:doc:`/tutorial/add-user-to-database` |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arg. is it easy to revert this?
(passive sentence here? includes make it easy to edit. sorry to waffle)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the "where the role is created" is OK. But if you want to reword, it'd be quick to do in the few files that use it.
I'm still liking not doing an include for this info because it's unlikely to change.