db.revokePrivilegesFromRole()
이 페이지의 내용
정의
db.revokePrivilegesFromRole(rolename, privileges, writeConcern)
메서드가 실행되는 데이터베이스의 사용자 정의 역할에서 지정된 권한을 제거합니다.
중요
Mongo쉬 방법
이 페이지에서는
mongosh
메서드를 설명합니다. 이는 데이터베이스 명령 또는 Node.js와 같은 언어별 드라이버에 대한 설명서가 아닙니다.데이터베이스 명령에 대해서는
revokePrivilegesFromRole
명령을 참조하십시오.MongoDB API 드라이버의 경우 언어별 MongoDB 드라이버 설명서를 참조하세요.
레거시
mongo
셸 문서는 해당 MongoDB 서버 릴리스 문서를 참조하세요.db.revokePrivilegesFromRole()
메서드의 구문은 다음과 같습니다.db.revokePrivilegesFromRole( "<rolename>", [ { resource: { <resource> }, actions: [ "<action>", ... ] }, ... ], { <writeConcern> } ) db.revokePrivilegesFromRole()
메서드는 다음 인수를 사용합니다.매개 변수유형설명rolename
문자열권한을 취소할 사용자 정의 역할의 이름입니다.privileges
배열역할에서 제거할 권한의 배열입니다. 권한 형식에 대한 자세한 내용은privileges
를 참조하세요.writeConcern
문서
행동
복제본 세트
복제본 세트에서 실행할 경우, db.revokePrivilegesFromRole()
는 기본값으로 "majority"
쓰기 고려(write concern)를 사용하여 실행됩니다.
범위
권한을 취소하려면 리소스 문서 패턴이 해당 권한의 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" ] } ] )
필요한 액세스 권한
해당 권한을 취소하려면 권한 대상 데이터베이스에 대한 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" } )