AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

cancelPrivilegesFromRole (데이터베이스 명령)

revokePrivilegesFromRole

명령이 실행되는 데이터베이스의 사용자 정의 역할에서 지정된 권한을 제거합니다.

In mongosh, this command can also be run through the db.revokePrivilegesFromRole() helper method.

Helper methods are convenient for mongosh users, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command.

이 명령은 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.

  • MongoDB Atlas: 클라우드에서의 MongoDB 배포를 위한 완전 관리형 서비스

중요

이 명령은 M0 및 Flex 클러스터에서 지원되지 않습니다. 자세한 내용은 지원되지 않는 명령을 참조하세요.

명령은 다음과 같은 구문을 가집니다:

db.runCommand(
{
revokePrivilegesFromRole: "<role>",
privileges: [
{ resource: { <resource> }, actions: [ "<action>", ... ] },
...
],
writeConcern: <write concern document>,
comment: <any>
}
)

이 명령은 다음 필드를 사용합니다.

필드
유형
설명

revokePrivilegesFromRole

문자열

권한을 취소할 사용자 정의 역할입니다.

privileges

배열

역할에서 제거할 권한의 배열입니다. 권한 형식에 대한 자세한 내용은 privileges 를 참조하세요.

writeConcern

문서

선택 사항입니다. 작업에 대한 쓰기 고려 수준입니다. 쓰기 고려 사양을 참조하세요.

comment

any

선택 사항. 이 명령에 첨부할 사용자 제공 코멘트입니다. 설정되면 이 설명은 다음 위치에서 이 명령의 레코드와 함께 표시됩니다.

댓글은 유효한 모든 BSON types (문자열, 정수, 객체, 배열 등)이 될 수 있습니다.

권한을 취소하려면 리소스 문서 패턴이 해당 권한의 resource 필드와 정확히 일치해야 합니다. actions 필드는 하위 집합이거나 정확히 일치할 수 있습니다.

예를 들어, products 데이터베이스를 리소스로 지정하는 다음 권한을 가진 products 데이터베이스에서 accountRole 역할이 있다고 가정합니다.

{
"resource" : {
"db" : "products",
"collection" : ""
},
"actions" : [
"find",
"update"
]
}

products 데이터베이스의 하나 의 컬렉션에서만 find 및/또는 update 을(를) 해지할 수 없습니다 . 다음 작업을 수행해도 역할이 변경되지 않습니다.

use products
db.runCommand(
{
revokePrivilegesFromRole: "accountRole",
privileges:
[
{
resource : {
db : "products",
collection : "gadgets"
},
actions : [
"find",
"update"
]
}
]
}
)
db.runCommand(
{
revokePrivilegesFromRole: "accountRole",
privileges:
[
{
resource : {
db : "products",
collection : "gadgets"
},
actions : [
"find"
]
}
]
}
)

accountRole 역할에서 "find" 및/또는 "update" 작업을 취소하려면 리소스 문서와 정확히 일치해야 합니다. 예를 들어, 다음 작업은 기존 권한에서 "find" 작업만 취소합니다.

use products
db.runCommand(
{
revokePrivilegesFromRole: "accountRole",
privileges:
[
{
resource : {
db : "products",
collection : ""
},
actions : [
"find"
]
}
]
}
)

해당 권한을 취소하려면 권한 대상 데이터베이스에 대한 revokeRole 작업 이 있어야 합니다. 권한이 여러 데이터베이스 또는 cluster 리소스를 대상으로 하는 경우 admin 데이터베이스에 대한 revokeRole 작업이 있어야 합니다.

다음 작업은 products 데이터베이스의 associates 역할에서 여러 권한을 제거합니다.

use products
db.runCommand(
{
revokePrivilegesFromRole: "associate",
privileges:
[
{
resource: { db: "products", collection: "" },
actions: [ "createCollection", "createIndex", "find" ]
},
{
resource: { db: "products", collection: "orders" },
actions: [ "insert" ]
}
],
writeConcern: { w: "majority" }
}
)