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

db.revokePrivilegesFromRole() (mongosh 메서드)

db.revokePrivilegesFromRole(rolename, privileges, writeConcern)

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

중요

Mongo쉬 방법

This page documents a mongosh method. This is not the documentation for database commands or language-specific drivers, such as Node.js.

데이터베이스 명령에 대해서는 revokePrivilegesFromRole 명령을 참조하십시오.

MongoDB API 드라이버의 경우 언어별 MongoDB 드라이버 설명서를 참조하세요.

The db.revokePrivilegesFromRole() method has the following syntax:

db.revokePrivilegesFromRole(
"<rolename>",
[
{ resource: { <resource> }, actions: [ "<action>", ... ] },
...
],
{ <writeConcern> }
)

The db.revokePrivilegesFromRole() method takes the following arguments:

Parameter
유형
설명

rolename

문자열

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

privileges

배열

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

writeConcern

문서

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

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

중요

이 명령은 MongoDB Atlas 클러스터에서 지원되지 않습니다. 모든 명령에 대한 Atlas 지원에 관해 자세히 알아보려면 지원되지 않는 명령을 참조하세요.

If run on a replica set, db.revokePrivilegesFromRole() is executed using "majority" write concern by default.

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

예를 들어 products 데이터베이스를 리소스로 지정하는 다음 권한이 있는 products 데이터베이스에 accountRole 역할이 주어집니다.

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

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

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

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

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

privileges 배열 지정하면 데이터베이스의 여러 컬렉션 또는 전체 데이터베이스에 적용 권한 을 지정할 수 있습니다.

다음 구문은 products 데이터베이스 의 여러 컬렉션에 대한 권한을 지정합니다.

privileges: [
{
resource: { db: 'products', collection: 'coll1' },
actions: [ 'bypassDocumentValidation' ]
},
{
resource: { db: 'products', collection: 'coll2' },
actions: [ 'bypassDocumentValidation' ]
}
]

다음 구문은 products 데이터베이스 의 모든 컬렉션에 대한 권한을 지정합니다.

privileges: [
{
resource: { db: 'products', collection: '' },
actions: [ 'bypassDocumentValidation' ]
}
]

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

다음 작업은 associates 역할에서 여러 권한을 제거합니다.

db.revokePrivilegesFromRole(
"associate",
[
{
resource: { db: "products", collection: "" },
actions: [ "createCollection", "createIndex", "find" ]
},
{
resource: { db: "products", collection: "orders" },
actions: [ "insert" ]
}
],
{ w: "majority" }
)
이 페이지 평가하기