架构师_程序员_码农网

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

搜索
查看: 6808|回复: 1

MongoDB权限角色表

[复制链接]
发表于 2016-10-9 17:04:10 | 显示全部楼层 |阅读模式
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 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.
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.
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, and system.namespaces collections. The role provides read access by granting the following actions:
  • collStats
  • dbHash
  • dbStats
  • find
  • killCursors
  • listIndexes
  • listCollections
readWrite
Provides all the privileges of the read role plus ability to modify data on all non-system collections and the system.js collection. The role provides the following actions on those collections:
  • collStats
  • convertToCapped
  • createCollection
  • dbHash
  • dbStats
  • dropCollection
  • createIndex
  • dropIndex
  • emptycapped
  • find
  • insert
  • killCursors
  • listIndexes
  • listCollections
  • remove
  • renameCollectionSameDB
  • update

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.profile collections:
  • collStats
  • dbHash
  • dbStats
  • find
  • killCursors
  • listIndexes
  • listCollections
  • dropCollection and createCollection on system.profile only
Changed in version 2.6.4: dbAdmin added the createCollection for the system.profilecollection. Previous versions only had the dropCollection on the system.profile collection.

Provides the following actions on all non-system collections. This role does not include full read access on non-system collections:
  • bypassDocumentValidation
  • collMod
  • collStats
  • compact
  • convertToCapped
  • createCollection
  • createIndex
  • dbStats
  • dropCollection
  • dropDatabase
  • dropIndex
  • enableProfiler
  • reIndex
  • renameCollectionSameDB
  • repairDatabase
  • storageDetails
  • validate
dbOwner
The database owner can perform any administrative action on the database. This role combines the privileges granted by the readWrite, dbAdmin and userAdmin roles.
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.
The userAdmin role explicitly provides the following actions:
  • changeCustomData
  • changePassword
  • createRole
  • createUser
  • dropRole
  • dropUser
  • grantRole
  • revokeRole
  • viewRole
  • viewUser

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.
clusterAdmin
Provides the greatest cluster-management access. This role combines the privileges granted by theclusterManager, clusterMonitor, and hostManager roles. Additionally, the role provides thedropDatabase action.
clusterManager
Provides management and monitoring actions on the cluster. A user with this role can access the configand local databases, which are used in sharding and replication, respectively.
Provides the following actions on the cluster as a whole:
  • addShard
  • applicationMessage
  • cleanupOrphaned
  • flushRouterConfig
  • listShards
  • removeShard
  • replSetConfigure
  • replSetGetConfig
  • replSetGetStatus
  • replSetStateChange
  • resync
Provides the following actions on all databases in the cluster:
  • enableSharding
  • moveChunk
  • splitChunk
  • splitVector
On the config database, provides the following actions on the settings collection:
  • insert
  • remove
  • update
On the config database, provides the following actions on all configuration collections and on thesystem.indexes, system.js, and system.namespaces collections:
  • collStats
  • dbHash
  • dbStats
  • find
  • killCursors
On the local database, provides the following actions on the replset collection:
  • collStats
  • dbHash
  • dbStats
  • find
  • killCursors
clusterMonitor
Provides read-only access to monitoring tools, such as the MongoDB Cloud Manager and Ops Manager monitoring agent.
Provides the following actions on the cluster as a whole:
  • connPoolStats
  • cursorInfo
  • getCmdLineOpts
  • getLog
  • getParameter
  • getShardMap
  • hostInfo
  • inprog
  • listDatabases
  • listShards
  • netstat
  • replSetGetStatus
  • replSetGetConfig
  • serverStatus
  • shardingState
  • top
Provides the following actions on all databases in the cluster:
  • collStats
  • dbStats
  • getShardVersion
  • indexStats
Provides the find action on all system.profile collections in the cluster.
Provides the following actions on the config database’s configuration collections andsystem.indexes, system.js, and system.namespaces collections:
  • collStats
  • dbHash
  • dbStats
  • find
  • killCursors
hostManager
Provides the ability to monitor and manage servers.
Provides the following actions on the cluster as a whole:
  • applicationMessage
  • closeAllDatabases
  • connPoolSync
  • cpuProfiler
  • diagLogging
  • flushRouterConfig
  • fsync
  • invalidateUserCache
  • killop
  • logRotate
  • resync
  • setParameter
  • shutdown
  • touch
  • unlock
Provides the following actions on all databases in the cluster:
  • killCursors
  • repairDatabase

Backup and Restoration Roles
The admin database includes the following roles for backing up and restoring data:
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 entire mongod instance.
Provides the insert and update actions on the mms.backup collection in the admin database and on the settings collection in the config database.
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 bypassDocumentValidation action for collections that have document validation.
Provides the find action on the following:
  • all non-system collections in the cluster
  • all the following system collections in the cluster: system.indexes, system.namespaces, and system.js
  • the admin.system.users and admin.system.roles collections
  • the config.settings collection
  • legacy system.users collections from versions of MongoDB prior to 2.6
Changed in version 3.2.1: The backup role provides additional privileges to back up thesystem.profile collections that exist when running with database profiling. Previously, users required an additional read access on this collection.

restore
Provides privileges needed to restore data from backups that do not include system.profilecollection data. This role is sufficient when restoring data with mongorestore without the --oplogReplay option.
  • If the backup data includes system.profile collection data and the target database does not contain the system.profile collection, mongorestore attempts to create the collection even though the program does not actually restore system.profile documents. As such, the user requires additional privileges to perform createCollection and convertToCapped actions on the system.profile collection for a database.
    The built-in roles dbAdmin and dbAdminAnyDatabase provide the additional privileges.
  • If running mongorestore with --oplogReplay, the restore role is insufficient to replay the oplog. To replay the oplog, create a user-defined role that has anyAction on anyResource and grant only to users who must run mongorestore with --oplogReplay.

Provides the following actions on all non-system collections and system.js collections in the cluster; on the admin.system.users and admin.system.roles collections in the admin database; and on legacy system.users collections from versions of MongoDB prior to 2.6:
  • collMod
  • createCollection
  • createIndex
  • dropCollection
  • insert
Provides the listCollections action on all databases.
Provides the following additional actions on admin.system.users and legacy system.userscollections:
  • find
  • remove
  • update
Provides the find action on all the system.namespaces collections in the cluster.
Although, restore includes the ability to modify the documents in the admin.system.userscollection using normal modification operations, only modify these data using the user management methods.

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:
readAnyDatabase
Provides the same read-only permissions as read, except it applies to all databases in the cluster. The role also provides the listDatabases action on the cluster as a whole.
readWriteAnyDatabase
Provides the same read and write permissions as readWrite, except it applies to all databases in the cluster. The role also provides the listDatabases action on the cluster as a whole.
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:
  • authSchemaUpgrade
  • invalidateUserCache
  • listDatabases
The role also provides the following actions on the admin.system.users andadmin.system.roles collections on the admin database, and on legacy system.userscollections from versions of MongoDB prior to 2.6:
  • collStats
  • dbHash
  • dbStats
  • find
  • killCursors
  • planCacheRead
Changed in version 2.6.4: userAdminAnyDatabase added the following permissions on theadmin.system.users and admin.system.roles collections:
  • createIndex
  • dropIndex

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.
dbAdminAnyDatabase
Provides the same access to database administration operations as dbAdmin, except it applies to alldatabases in the cluster. The role also provides the listDatabases action on the cluster as a whole.

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 the admin database
  • userAdmin role, when scoped to the admin database
  • 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.
Changed in version 3.0.7: The root has validate action on system. collections. Previously, rootdoes not include any access to collections that begin with the system. prefix other thansystem.indexes and system.namespaces.
The root role includes privileges from the restore role.


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.
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 grants anyAction on anyResource and ensure that only the users who need access to these operations have this access.
原文:https://docs.mongodb.com/manual/reference/built-in-roles/#built-in-roles






上一篇:c# 反射获取对象属性的displayname
下一篇:MongoDb创建账号和密码登陆
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
 楼主| 发表于 2016-10-9 17:33:26 | 显示全部楼层
MongoDb创建账号和密码登陆
http://www.itsvse.com/thread-3221-1-1.html
(出处: 码农网)
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

免责声明:
码农网所发布的一切软件、编程资料或者文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:help@itsvse.com

QQ|手机版|小黑屋|架构师 ( 鲁ICP备14021824号-2 )|网站地图

GMT+8, 2025-6-16 04:02

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表