關於芒果的權限控制說白了就是定義 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-system collections in the role’s database and at the collection level for all system collections.
每個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 showBuiltinRolesfields both set to true.
這節描述了各個內置角色的權限。你可以發出rolesInfo的命令:把showPrivileges 和showBuiltinRolesfields 設為true,在任何時間查看內置角色的權限。
Database User Roles
Every database includes the following client roles:
每個數據庫都包含以下客戶角色:
-
read -
讀 -
Provides the ability to read data on all non-system collections and on the following system collections:
system.indexes,system.js, andsystem.namespacescollections. The role provides read access by granting the following actions:提供能力讀取非系統集合和以下系統集合
system.indexes,system.js, andsystem.namespaces的集合。該角色通過授予以下動作來提供讀的權限:
Database Administration Roles
Every database includes the following database administration roles:
每個數據庫都包含以下管理角色:
-
dbAdmin -
數據庫管理員 -
Provides the following actions on the database’s
system.indexes,system.namespaces, andsystem.profilecollections:為數據庫的
system.indexes,system.namespaces,system.profile集合提供以下操作:collStatsdbHashdbStatsfindkillCursorslistIndexeslistCollectionsdropCollectionandcreateCollectiononsystem.profileonly
Changed in version 2.6.4:
dbAdminadded thecreateCollectionfor thesystem.profilecollection. Previous versions only had thedropCollectionon thesystem.profilecollection.更改於版本2.6.4:dbAdmin 為了
system.profile添加createCollection。更早的版本在system.profile集合上只有dropCollectionProvides the following actions on all non-system collections. This role does not include full read access on non-system collections:
-
dbOwner -
數據庫所有者 -
The database owner can perform any administrative action on the database. This role combines the privileges granted by the
readWrite,dbAdminanduserAdminroles.數據庫所有者可以執行數據庫所有管理的操作。這個角色合並了
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
admindatabase, the cluster. TheuserAdminrole allows users to grant any user any privilege, including themselves.提供在當前數據庫創建和修改角色和用戶的能力。這個角色也可以直接提供超級權限要么到數據庫,要么,如果范圍僅僅是admin數據庫,這個簇群。用戶管理員角色允許用戶授權任意用戶的權限,包括它們自己的。
-
The
userAdminrole explicitly provides the following actions:用戶管理員角色明確的提供以下的操作:
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, andhostManagerroles. Additionally, the role provides thedropDatabaseaction.提供最高集群管理權限。這個角色包括了
clusterManager,clusterMonitor,hostManager角色的權限,這個角色提供了dropDatabase的操作。
-
clusterManager -
集群管理者 -
Provides management and monitoring actions on the cluster. A user with this role can access the
configandlocaldatabases, which are used in sharding and replication, respectively.在集群上提供管理和監視操作。一個擁有此角色用戶可以有權管理分別被用來共享、復制的設置和本地數據庫
Provides the following actions on the cluster as a whole:
把集群看成一個整體的基礎上提供以下操作:
addShardapplicationMessagecleanupOrphanedflushRouterConfiglistShardsremoveShardreplSetConfigurereplSetGetStatusreplSetStateChangeresync
Provides the following actions on all databases in the cluster:
在集群中的所有數據庫提供以下方法:
On the
configdatabase, provides the following actions on thesettingscollection:在配置數據庫中, 為
settings集合提供以下的操作On the
configdatabase, provides the following actions on all configuration collections and on thesystem.indexes,system.js, andsystem.namespacescollections:在配置數據庫里,為configuration,
system.indexes,system.js,system.namespaces集合提供以下操作:On the
localdatabase, provides the following actions on thereplsetcollection:在本地數據庫里,為
replset集合提供以下操作:
-
clusterMonitor -
集合監視者 -
Provides read-only access to monitoring tools, such as the MongoDB Cloud Manager and Ops Managermonitoring agent.
Provides the following actions on the cluster as a whole:
為監視工具提供只讀的權限,包括 MongoDB Cloud Manager 和Ops Managermonitoring agent兩個工具。
把集群看成一個整體的基礎上提供以下操作:
connPoolStatscursorInfogetCmdLineOptsgetLoggetParametergetShardMaphostInfoinproglistDatabaseslistShardsnetstatreplSetGetStatusserverStatusshardingStatetop
Provides the following actions on all databases in the cluster:
在集群中的所有數據庫提供以下方法:
Provides the
findaction on allsystem.profilecollections in the cluster.Provides the following actions on the
configdatabase’s configuration collections andsystem.indexes,system.js, andsystem.namespacescollections:為所有在集群里的
system.profile集合提供find操作:
-
hostManager - 主機管理者
-
Provides the ability to monitor and manage servers.
提供監視和管理服務器的能力。
Provides the following actions on the cluster as a whole:
把集群看成一個整體的基礎上提供以下操作:
applicationMessagecloseAllDatabasesconnPoolSynccpuProfilerdiagLoggingflushRouterConfigfsyncinvalidateUserCachekilloplogRotateresyncsetParametershutdowntouchunlock
Provides the following actions on all databases in the cluster:
在集群中的所有數據庫提供以下方法:
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
mongodumpto back up an entiremongodinstance.提供最低的權限為了備份數據的需要。這個角色提供了足夠的權限來使用MongoDB Cloud Manager 備份代理, Ops Manager代理,或者使用
mongodump來備份怎個mongod實例。Provides the following actions on the
mms.backupcollection in theadmindatabase:為
admin數據庫的mms.backup集合提供以下操作:Provides the
listDatabasesaction on the cluster as a whole.把集群看成一個整體的基礎上提供
listDatabases操作。Provides the
listCollectionsaction on all databases.在集群中的所有數據庫提供
listCollections方法。Provides the
listIndexesaction for all collections.在所有集合提供
listIndexes方法。Provides the
bypassDocumentValidationaction for collections that have document validation.在有document validation的集合提供
listIndexes方法。Provides the
findaction on the following:為以下提供
find方法:- all non-system collections in the cluster
- 所有在集群里的所有非系統集合
- all the following system collections in the cluster:
system.indexes,system.namespaces, andsystem.js - 所有在集群里的系統集合
system.indexes,system.namespaces,system.js - the
admin.system.usersandadmin.system.rolescollections -
admin.system.users和admin.system.roles集合 - legacy
system.userscollections from versions of MongoDB prior to 2.6 - 在2.6版本之前遺留的
system.users集合
To back up the
system.profilecollection, which is created when you activate database profiling, you must have additionalreadaccess on this collection. Several roles provide this access, including theclusterAdminanddbAdminroles.為了備份當你啟用了數據壓縮時被創建的
system.profile集合,對這個集合你必須獲得額外的讀取權限。若干角色提供這個權限,包括clusterAdmin和dbAdmin角色。
-
restore -
還原 -
Provides privileges needed to restore data from backups. This role is sufficient when restoring data with
mongorestorewithout the --oplogReplay option. If runningmongorestorewith --oplogReplay, however, therestorerole is insufficient to replay the oplog. To replay the oplog, create a user-defined role that hasanyActionon anyResource and grant only to users who must runmongorestorewith --oplogReplay.提供還原備份所需權限。這個角色在沒有設置--oplogReplay 選項的時候有充足的權限使用
mongorestore還原數據。如果在運行mongorestore設置了--oplogReplay 選項,restore角色無論如何沒有充足的權限應用操作日志。Provides the following actions on all non-system collections and
system.jscollections in the cluster; on theadmin.system.usersandadmin.system.rolescollections in theadmindatabase; and on legacysystem.userscollections from versions of MongoDB prior to 2.6:為集群中的非系統集合,
system.js集合admin數據庫的admin.system.users和admin.system.roles集合和2.6版本之前遺留的system.users集合提供了以下操作:Provides the
listCollectionsaction on all databases.為所有數據庫提供
listCollections操作Provides the following additional actions on
admin.system.usersand legacysystem.userscollections:為
admin.system.users和遺留的system.userscollections提供額外的操作:Provides the
findaction on all thesystem.namespacescollections in the cluster.為集群的
system.namespaces集合提供。find操作Although,
restoreincludes the ability to modify the documents in theadmin.system.userscollection using normal modification operations, only modify these data using the user management methods.雖然restore角色包含了可以使用普通修改方法去修改
admin.system.users集合內文檔的能力,但是僅僅只能使用 用戶管理方法修改這些數據。
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 thelistDatabasesaction 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 thelistDatabasesaction 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.usersandadmin.system.rolescollections on theadmindatabase, and on legacysystem.userscollections from versions of MongoDB prior to 2.6:該角色也為原有早於2.6版本的admin數據庫的
admin.system.users和admin.system.roles集合提供了以下操作:Changed in version 2.6.4:
userAdminAnyDatabaseadded the following permissions on theadmin.system.usersandadmin.system.rolescollections:在版本2.6.4的更改:
userAdminAnyDatabase角色添加了對admin.system.users和admin.system.roles的權限。The
userAdminAnyDatabaserole does not restrict the permissions that a user can grant. As a result,userAdminAnyDatabaseusers 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 thelistDatabasesaction 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:
下面的角色提供了任何數據任何用戶的任何權限的能力,擁有這個角色的用戶可以在任何數據庫上定義它們自己的權限。
dbOwnerrole, when scoped to theadmindatabase 作用於admin數據庫時userAdminrole, when scoped to theadmindatabase 作用於admin數據庫時userAdminAnyDatabaserole
The following role provides full privileges on all resources:
下面的角色提供了全部資源的全部權限:
-
root -
Provides access to the operations and all the resources of the
readWriteAnyDatabase,dbAdminAnyDatabase,userAdminAnyDatabase,clusterAdminroles,restorecombined.提供了所有資源的所有操作,包括
readWriteAnyDatabase,dbAdminAnyDatabase,userAdminAnyDatabase,clusterAdmin,restore 角色的權限。Changed in version 3.0.7: The
roothasvalidateaction onsystem.collections. Previously,rootdoes not include any access to collections that begin with thesystem.prefix.3.0.7版本修改了:root角色在系統上有
validate操作的權限,在以前的版本中,root角色沒有包含system.前綴集合的權限。The
rootincludes privileges fromrestore.root角色包括了restore角色的權限。
Internal Role
-
__system -
系統角色 -
MongoDB assigns this role to user objects that represent cluster members, such as replica set members and
mongosinstances. 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
applyOpscommands, do not assign this role. Instead, create a user-defined role that grantsanyActionon anyResource and ensure that only the users who need access to these operations have this access.不要給應用程序或者管理人員分配這個角色,除了特殊情況。如果你需要對所有資源進行所有操作,舉個例子,運行
applyOps命令,不要分配這個角色。反之,create a user-defined role 這個操作需要 anyResource 的anyAction授權,確保只有需要這些操作的用戶擁有這個權限。
