MongoDB提供一些内置角色,它给数据库系统提供了不一样的访问级别。每一个数据库都有内置的数据库用户角色和数据库管理角色。admin数据库则包含了额外的一些角色。mongodb
本页面简单描述了这些内置角色。每一个角色所赋予的特定的权限,请看Build-in Roles参考页。数据库
每一个数据库包含以下角色:app
Role | Short Description |
---|---|
read | For the specific privileges granted by the role, see read.ide 提供对于non-system collections和如下system collections(system.indexes,system.js和system.namespaces)的读权限。ui
|
readWrite | For the specific privileges granted by the role, see readWrite.this 提供了全部read所具备的权限,同时还具备修改non-system collections以及system.js collection的权限。spa |
每一个数据库包含如下数据库管理权限:rest
Role | Short Description |
---|---|
dbAdmin | For the specific privileges granted by the role, see dbAdmin.orm 能够执行schema相关工做,建立索引/收集统计数据等。该角色没有用户和角色管理权限。server |
dbOwner | 能够管理数据库。它包含了readWrite/dbAdmin/userAdmin的角色权限。 |
userAdmin | For the specific privileges granted by the role, see userAdmin. 能够在当前数据库建立和修改用户和角色。由于userAdmin容许相应用户将任何特权授予给任何用户,因此该角色能够间接给数据库提供超级用户的权限,若是做用到admin数据库,还能够对集群提供超级用户的权限。 |
admin数据库为管理整个数据库系统提供了如下角色。这些角色包含了副本集和分片集群,但不限于此。
Role | Short Description |
---|---|
clusterAdmin | 集群管理提供了集群管理的最高权限。该角色包含的权限涵盖clusterManager, clusterMonitor,hostManager。 另外,该角色可执行dropDatabase |
clusterManager | For the specific privileges granted by the role, see clusterManager. 提供了管理和监控集群的功能。被赋予此角色的用户能够访问config/local数据库,这些数据库分别被用于分片和副本。 |
clusterMonitor | For the specific privileges granted by the role, see clusterMonitor. 为MongoDB Cloud Manager和Ops Manager监控agent提供只读访问权限。 |
hostManager | 用于监控和管理server For the specific privileges granted by the role, see hostManager. |
admin数据库包含以下备份和恢复数据的角色。
Role | Short Description |
---|---|
backup | 提供备份数据所需的特权。该角色提供足够的权限来使用MongoDB云管理备份agent/Ops Manager备份agent,或mongodump。 For the specific privileges granted by the role, see backup. |
restore | Provides privileges needed to restore data with mongorestore without the --oplogReplay option or without system.profile collection data. 提供了使用mongorestore恢复数据的权限,mongorestore不能带有参数--oplogReplay,也不能使用system.profile collection的数据。 For the specific privileges granted by the role, see restore. |
admin数据库提供了如下角色能够应用到全部数据库,和单个数据库中的角色大体等同。
Role | Short Description |
---|---|
readAnyDatabase | 和read提供相同的权限,只不过是该角色应用到全部数据库。该角色同时能够在整个集群上使用listDatabases命令。 For the specific privileges granted by the role, see readAnyDatabase. |
readWriteAnyDatabase | 和readWrite提供相同的权限,只不过是该角色应用到全部数据库。该角色同时能够在整个集群上使用listDatabases命令。 For the specific privileges granted by the role, see readWriteAnyDatabase. |
userAdminAnyDatabase | 和userAdmin提供相同的权限,只不过是该角色应用到全部数据库。 由于userAdminAnyDatabase容许全部权限赋予给全部用户,包括自身,因此间接提供了superuser权限。 For the specific privileges granted by the role, see userAdminAnyDatabase. |
dbAdminAnyDatabase | 和dbAdmin提供相同的权限,只不过是该角色应用到全部数据库。该角色同时能够在整个集群上使用listDatabases命令。 For the specific privileges granted by the role, see dbAdminAnyDatabase. |
如下角色对全部资源提供所有的权限:
Role | Short Description |
---|---|
root | Provides access to the operations and all the resources of thereadWriteAnyDatabase, dbAdminAnyDatabase, userAdminAnyDatabaseand clusterAdmin roles combined. For the specific privileges granted by the role, see root. |
内部角色
Role | Short Description |
---|---|
__system | Provides privileges to take any action against any object in the database. Do not assign this role to user objects representing applications or human administrators, other than in exceptional circumstances. For more information, see root. |
https://docs.mongodb.com/manual/core/security-built-in-roles/