MongoDB的內建角色 Built-In Roles
關於芒果的許可權控制說白了就是定義 Role(角色) 來控制對資料庫進行的操作(呼叫的方法比如查詢方法find)。
系統內建的Role分為 以下幾大類:
Database User Roles 這個是針對非系統資料庫和部分系統表的角色組
Database Administration Roles 可以操作所有資料庫
Cluster Administration Roles 管理員族 針對整個系統進行管理
Backup and Restoration Roles 備份還原角色組
All-Database Roles 角色裡面有一些跟超管差不多了級別了,針對所有資料庫的
Superuser Roles 超級管理員 不用多說了
Internal Role 內部系統角色,比超管牛,別亂設哦
翻譯的很爛,湊合看吧,有糾正我的請留言。
MongoDB grants access to data and commands through role-based authorization and provides built-in roles that provide the different levels of access commonly needed in a database system. You can additionally createuser-defined roles.
芒果通過角色基本許可權控制授予(使用者)資料和命令的使用權,並且提供給內建角色資料系統一般需要的不同層次的許可權。另外,你也可以建立使用者定義角色。
A role grants privileges to perform sets of actions on defined resources. A given role applies to the database on which it is defined and can grant access down to a collection level of granularity.
一個角色授予許可權去執行被定義資源的操作設定。一個給定的角色適用於被定義並且可以授予集合水平力度的資料庫。
Each of MongoDB’s built-in roles defines access at the database level for all non
每個MongoDB的內建角色定義了訪問資料庫級的角色的資料庫中所有非系統的集合和集合級別的系統集合。
MongoDB provides the built-in database user and database administration roles on every database. MongoDB provides all other built-in roles only on the admin
database.
芒果在每個資料庫上提供了內建資料庫使用者和和資料庫管理員角色。芒果僅僅在admin資料庫上提供了所有其他內建角色。
This section describes the privileges for each built-in role. You can also view the privileges for a built-in role at any time by issuing the rolesInfo
command with the showPrivileges
and showBuiltinRoles
fields both set to true
.
這節描述了各個內建角色的許可權。你可以發出rolesInfo的命令:把showPrivileges
和showBuiltinRoles
fields 設為true,在任何時間檢視內建角色的許可權。
Database User Roles
資料庫使用者角色Every database includes the following client roles:
每個資料庫都包含以下客戶角色:
Database Administration Roles
資料庫管理角色Every database includes the following database administration roles:
每個資料庫都包含以下管理角色:
dbOwner
資料庫所有者
-
The database owner can perform any administrative action on the database. This role combines the privileges granted by the
readWrite
,dbAdmin
anduserAdmin
roles.資料庫所有者可以執行資料庫所有管理的操作。這個角色合併了
readWrite
,dbAdmin
,userAdmin角色的許可權
userAdmin
- 使用者管理員
-
Provides the ability to create and modify roles and users on the current database. This role also indirectly provides superuser access to either the database or, if scoped to the
admin
database, the cluster. TheuserAdmin
role allows users to grant any user any privilege, including themselves.提供在當前資料庫建立和修改角色和使用者的能力。這個角色也可以直接提供超級許可權要麼到資料庫,要麼,如果範圍僅僅是admin資料庫,這個簇群。使用者管理員角色允許使用者授權任意使用者的許可權,包括它們自己的。
Cluster Administration Roles
叢集管理角色The admin
database includes the following roles for administering the whole system rather than just a single database. These roles include but are not limited to replica set and sharded cluster administrative functions.
為了管理整個系統而不是僅僅單個數據庫,admin資料庫包括以下的角色。這些角色包括但不受 replica set 和sharded cluster 管理方法的限制
clusterAdmin
- 叢集管理員
-
Provides the greatest cluster-management access. This role combines the privileges granted by the
clusterManager
,clusterMonitor
, andhostManager
roles. Additionally, the role provides thedropDatabase
action.提供最高叢集管理許可權。這個角色包括了
clusterManager
,clusterMonitor
,hostManager角色的許可權,這個角色提供了
clusterManager
叢集管理者
-
Provides management and monitoring actions on the cluster. A user with this role can access the
config
andlocal
databases, which are used in sharding and replication, respectively.在叢集上提供管理和監視操作。一個擁有此角色使用者可以有權管理分別被用來共享、複製的設定和本地資料庫
Provides the following actions on the cluster as a whole:
把叢集看成一個整體的基礎上提供以下操作:
Provides the following actions on all databases in the cluster:
在叢集中的所有資料庫提供以下方法:
On the
config
database, provides the following actions on thesettings
collection:在配置資料庫中, 為提供以下
的
操作On the
config
database, provides the following actions on all configuration collections and on thesystem.indexes
,system.js
, andsystem.namespaces
collections:On the
local
database, provides the following actions on thereplset
collection:在本地資料庫裡,為
replset
集合提供以下操作:
Backup and Restoration Roles
備份和恢復角色The admin
database includes the following roles for backing up and restoring data:
admin資料庫包括以下備份和恢復的角色:
backup
備份
-
Provides minimal privileges needed for backing up data. This role provides sufficient privileges to use theMongoDB Cloud Manager backup agent, Ops Manager backup agent, or to use
mongodump
to back up an entiremongod
instance.Provides the following actions on the
mms.backup
collection in theadmin
database:為
admin
資料庫的mms.backup集合提供以下操作:Provides the
listDatabases
action on the cluster as a whole.Provides the
listCollections
action on all databases.Provides the
listIndexes
action for all collections.Provides the
find
action on the following:為以下提供
find
方法:To back up the
system.profile
collection, which is created when you activate database profiling, you must have additionalread
access on this collection. Several roles provide this access, including theclusterAdmin
anddbAdmin
roles.為了備份當你啟用了資料壓縮時被建立的
system.profile集合,對這個集合你必須獲得額外的讀取許可權。若干角色提供這個許可權,包括
clusterAdmin
和dbAdmin角色。
restore
還原
-
Provides privileges needed to restore data from backups. This role is sufficient when restoring data with
mongorestore
without the --oplogReplay option. If runningmongorestore
with --oplogReplay, however, therestore
role is insufficient to replay the oplog. To replay the oplog, create a user-defined role that hasanyAction
on anyResource and grant only to users who must runmongorestore
with --oplogReplay.提供還原備份所需許可權。這個角色在沒有設定--oplogReplay 選項的時候有充足的許可權使用
mongorestore
還原資料。如果在執行mongorestore設定了--oplogReplay 選項,
restore
角色無論如何沒有充足的許可權應用操作日誌。Provides the following actions on all non-system collections and
system.js
collections in the cluster; on theadmin.system.users
andadmin.system.roles
collections in theadmin
database; and on legacysystem.users
collections from versions of MongoDB prior to 2.6:Provides the
listCollections
action on all databases.Provides the following additional actions on
admin.system.users
and legacysystem.users
collections:為
admin.system.users
和遺留的system.users
collections提供額外的操作:Provides the
find
action on all thesystem.namespaces
collections in the cluster.Although,
restore
includes the ability to modify the documents in theadmin.system.users
collection using normal modification operations, only modify these data using the user management methods.雖然restore角色包含了可以使用普通修改方法去修改
All-Database Roles
所有資料庫角色The admin
database provides the following roles that apply to all databases in a mongod
instance and are roughly equivalent to their single-database equivalents:
admin資料庫提供了以下角色適用於一個mongod
例項所有資料庫,這些角色基本相當於它們的單獨資料庫。
readAnyDatabase
- 讀任何資料庫
-
Provides the same read-only permissions as
read
, except it applies to all databases in the cluster. The role also provides thelistDatabases
action on the cluster as a whole.提供和read角色一樣的只讀許可權,除了適用於叢集內所有資料庫這個特性。這個角色也為整個叢集提供
listDatabases
操作。
readWriteAnyDatabase
讀寫任何資料庫
-
Provides the same read and write permissions as
readWrite
, except it applies to all databases in the cluster. The role also provides thelistDatabases
action on the cluster as a whole.提供和readWrite角色一樣的讀寫許可權,除了適用於叢集內所有資料庫這個特性。這個角色也為整個叢集提供
listDatabases
操作。
userAdminAnyDatabase
使用者管理任何資料庫
-
Provides the same access to user administration operations as
userAdmin
, except it applies to alldatabases in the cluster. The role also provides the following actions on the cluster as a whole:提供和userAdmin角色一樣的讀寫許可權,除了適用於叢集內所有資料庫這個特性。這個角色也為整個叢集提供以下操作:
The role also provides the following actions on the
admin.system.users
andadmin.system.roles
collections on theadmin
database, and on legacysystem.users
collections from versions of MongoDB prior to 2.6:The
userAdminAnyDatabase
role does not restrict the permissions that a user can grant. As a result,userAdminAnyDatabase
users can grant themselves privileges in excess of their current privileges and even can grant themselves all privileges, even though the role does not explicitly authorize privileges beyond user administration. This role is effectively a MongoDB system superuser.userAdminAnyDatabase
角色沒有限制使用者可以授予的許可權。結果是,userAdminAnyDatabase
的使用者們可以授予它們自己比現在更多的許可權,甚至是所有許可權,甚至不需要明確的設定超過使用者管理員許可權。這個角色實際上是芒果系統的超級使用者。
dbAdminAnyDatabase
任意資料庫管理員
-
Provides the same access to database administration operations as
dbAdmin
, except it applies to alldatabases in the cluster. The role also provides thelistDatabases
action on the cluster as a whole.提供和dbAdmin角色一樣的讀寫許可權,除了適用於叢集內所有資料庫這個特性。這個角色也為整個叢集提供
listDatabases
操作。
Superuser Roles
超級使用者角色Several roles provide either indirect or direct system-wide superuser access.
若干角色提供了直接的或者全系統直接的超級使用者許可權。
The following roles provide the ability to assign any user any privilege on any database, which means that users with one of these roles can assign themselves any privilege on any database:
下面的角色提供了任何資料任何使用者的任何許可權的能力,擁有這個角色的使用者可以在任何資料庫上定義它們自己的許可權。
dbOwner
role, when scoped to theadmin
database 作用於admin資料庫時userAdmin
role, when scoped to theadmin
database 作用於admin資料庫時userAdminAnyDatabase
role
The following role provides full privileges on all resources:
下面的角色提供了全部資源的全部許可權:
root
-
Provides access to the operations and all the resources of the
readWriteAnyDatabase
,dbAdminAnyDatabase
,userAdminAnyDatabase
,clusterAdmin
roles,restore
combined.提供了所有資源的所有操作,包括
readWriteAnyDatabase
,dbAdminAnyDatabase
,userAdminAnyDatabase
,clusterAdmin
,restore 角色的許可權。
Changed in version 3.0.7: The
root
hasvalidate
action onsystem.
collections. Previously,root
does not include any access to collections that begin with thesystem.
prefix.3.0.7版本修改了:root角色在系統上有
validate操作的許可權,在以前的版本中,root角色沒有包含system.字首集合的許可權。
The
root
includes privileges fromrestore
.root角色包括了restore角色的許可權。
Internal Role
內部角色__system
系統角色
-
MongoDB assigns this role to user objects that represent cluster members, such as replica set members and
mongos
instances. The role entitles its holder to take any action against any object in the database.芒果為叢集成員的使用者物件分配了這個角色,就像副本複本整合員和
mongos的例項們。這個角色有權使其持有者對任何資料庫物件進行任意操作。
Do not assign this role to user objects representing applications or human administrators, other than in exceptional circumstances.
If you need access to all actions on all resources, for example to run
applyOps
commands, do not assign this role. Instead, create a user-defined role that grantsanyAction
on anyResource and ensure that only the users who need access to these operations have this access.不要給應用程式或者管理人員分配這個角色,除了特殊情況。如果你需要對所有資源進行所有操作,舉個例子,執行