MongoDB Atlas,无法使用内置角色“atlasAdmin”创建角色

oknrviil  于 2023-03-22  发布在  Go
关注(0)|答案(1)|浏览(227)

我正在使用内置角色“Atlas管理员”。
运行命令时:

db.runCommand({
  "createRole": "555-read",
  "roles": [],
  "privileges": [
    {
      "actions": [
        "find"
      ],
      "resource": {
        "db": "qqq",
        "collection": "555"
      }
    }
  ]
})

我得到:

MongoServerError: not authorized on qqq to execute command { createRole: "555-read"

我认为“阿特拉斯管理员”应该有权访问一切?
或者我需要在atlas中有一些特定的特权吗?

qnakjoqk

qnakjoqk1#

正如我在评论中提到的,你不能在mongo shell中创建create roles。你可以用这个检查特权:

db.runCommand({ connectionStatus: 1 })
{
  authInfo: {
    authenticatedUsers: [ { user: 'atlas-admin', db: 'admin' } ],
    authenticatedUserRoles: [
      { role: 'atlasAdmin', db: 'admin' },
      { role: 'backup', db: 'admin' },
      { role: 'clusterMonitor', db: 'admin' },
      { role: 'dbAdminAnyDatabase', db: 'admin' },
      { role: 'enableSharding', db: 'admin' },
      { role: 'readWriteAnyDatabase', db: 'admin' }
    ]
  },
  ok: 1,
  operationTime: Timestamp({ t: 1679383010, i: 1 })
}

db.runCommand({ connectionStatus: 1, showPrivileges: 1 }).authInfo.authenticatedUserPrivileges.filter(x => x.resource.collection == 'system.roles')
[
  {
    resource: { db: 'admin', collection: 'system.roles' },
    actions: [ 'find' ]
  }
]

如您所见,您只能选择角色。userAdminuserAdminAnyDatabase权限未被授予。

相关问题