정의
rolesInfo사용자 정의 역할 과 기본 제공 역할을 모두 포함하여 지정된 역할에 대한 상속 및 권한 정보를 반환합니다.
The
rolesInfocommand can also retrieve all roles scoped to a database.
호환성
이 명령은 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.
- MongoDB Atlas: 클라우드에서의 MongoDB 배포를 위한 완전 관리형 서비스
참고
이 명령은 모든 MongoDB Atlas 클러스터에서 지원됩니다. 모든 명령에 대한 Atlas 지원에 관해 자세히 알아보려면 지원되지 않는 명령을 참조하세요.
MongoDB Enterprise: MongoDB의 구독 기반 자체 관리 버전
MongoDB Community: MongoDB의 소스 사용 가능 무료 자체 관리 버전
구문
명령은 다음과 같은 구문을 가집니다:
db.runCommand( { rolesInfo: { role: <name>, db: <db> }, showAuthenticationRestrictions: <Boolean>, showBuiltinRoles: <Boolean>, showPrivileges: <Boolean>, comment: <any> } )
명령 필드
이 명령은 다음 필드를 사용합니다.
필드 | 유형 | 설명 |
|---|---|---|
| 문자열, 문서, 배열 또는 정수 | The role(s) to return information about. For the syntax for specifying roles, see Behavior. |
| 부울 | 선택 사항입니다. 출력에 인증 제한 사항을 포함하려면 이 필드를 기본적으로 이 필드는 |
| 부울 | 선택 사항. |
| 부울 | 선택 사항. 다른 역할에서 상속된 권한과 직접 정의된 권한을 모두 포함하여 역할 권한을 표시하려면 필드 를 |
| any | 선택 사항. 이 명령에 첨부할 사용자 제공 코멘트입니다. 설정되면 이 설명은 다음 위치에서 이 명령의 레코드와 함께 표시됩니다.
댓글은 유효한 모든 BSON types (문자열, 정수, 객체, 배열 등)이 될 수 있습니다. |
행동
단일 역할에 대한 정보 반환
현재 데이터베이스 에서 역할 을 지정하려면 이름으로 역할 을 지정합니다.
{ rolesInfo: "<rolename>" }
다른 데이터베이스의 역할을 지정하려면 역할과 데이터베이스를 지정하는 문서로 역할을 지정합니다.
{ rolesInfo: { role: "<rolename>", db: "<database>" } }
여러 역할에 대한 정보 반환
여러 역할을 지정하려면 배열을 사용합니다. 배열의 각 역할을 문서 또는 string 로 지정합니다. 명령이 실행되는 데이터베이스에 역할이 있는 경우에만 string 을 사용합니다.
{ rolesInfo: [ "<rolename>", { role: "<rolename>", db: "<database>" }, ... ] }
데이터베이스의 모든 역할에 대한 정보 반환
명령이 실행되는 데이터베이스의 모든 역할을 지정하려면 rolesInfo: 1 을(를) 지정합니다. 기본적으로 MongoDB는 데이터베이스의 모든 사용자 정의 역할 을 표시합니다. 기본 제공 역할 도 포함하려면 매개변수-값 쌍 showBuiltinRoles: true 를 포함합니다.
{ rolesInfo: 1, showBuiltinRoles: true }
필요한 액세스 권한
역할 정보를 확인하려면 해당 역할을 명시적으로 부여 받았거나 역할 데이터베이스에 viewRole 조치가 있어야 합니다.
출력
rolesInfo.db역할 이 정의된 데이터베이스 입니다. 모든 데이터베이스 에는 내장 역할 이 있습니다. 데이터베이스 에는 사용자 정의 역할이 있을 수도 있습니다.
rolesInfo.isBuiltintrue값은 해당 역할 이 내장 역할 역할임을 나타냅니다.false값은 역할 이 사용자 정의 역할 임을 나타냅니다.
rolesInfo.inheritedRolesAll roles from which this role inherits privileges. This includes the roles in the
rolesInfo.rolesarray as well as the roles from which the roles in therolesInfo.rolesarray inherit privileges. All privileges apply to the current role. The documents in this field list the roles and the databases on which they are defined.
rolesInfo.privilegesThe privileges directly specified by this role; i.e. the array excludes privileges inherited from other roles. By default the output does not include the
privilegesfield. To include the field, specifyshowPrivileges: truewhen running therolesInfocommand.
rolesInfo.inheritedPrivilegesAll privileges granted by this role, including those inherited from other roles. By default the output does not include the
inheritedPrivilegesfield. To include the field, specifyshowPrivileges: truewhen running therolesInfocommand.
예시
이 섹션의 예에서는 rolesInfo 명령을 사용하여 다음을 수행하는 방법을 보여 줍니다.
단일 역할에 대한 정보 보기
다음 명령은 products 데이터베이스에 정의된 associate 역할에 대한 역할 상속 정보를 반환합니다.
db.runCommand( { rolesInfo: { role: "associate", db: "products" } } )
다음 명령은 명령이 실행되는 데이터베이스 의 siteManager 역할 에 대한 역할 상속 정보를 반환합니다.
db.runCommand( { rolesInfo: "siteManager" } )
다음 명령은 products 데이터베이스에 정의된 associate 역할에 대한 역할 상속과 권한을 모두 반환합니다.
db.runCommand( { rolesInfo: { role: "associate", db: "products" }, showPrivileges: true } )
여러 역할에 대한 정보 보기
다음 명령은 서로 다른 두 데이터베이스에 있는 두 역할에 대한 정보를 반환합니다.
db.runCommand( { rolesInfo: [ { role: "associate", db: "products" }, { role: "manager", db: "resources" } ] } )
다음은 역할 상속과 권한을 모두 반환합니다.
db.runCommand( { rolesInfo: [ { role: "associate", db: "products" }, { role: "manager", db: "resources" } ], showPrivileges: true } )
데이터베이스에 대한 모든 사용자 정의 역할 보기
다음 작업은 명령이 실행되는 데이터베이스에서 모든 사용자 정의 역할 과 권한을 포함하여 반환합니다.
db.runCommand( { rolesInfo: 1, showPrivileges: true } )
출력 예시(가독성을 위해 축약됨)
{ roles: [ { _id: 'products.associate', role: 'associate', db: 'products', privileges: [ { resource: { db: 'products', collection: '' }, actions: [ 'bypassDocumentValidation' ] } ], roles: [ { role: 'readWrite', db: 'products' } ], isBuiltin: false, inheritedRoles: [ { role: 'readWrite', db: 'products' } ], inheritedPrivileges: [ { resource: { db: 'products', collection: '' }, actions: [ 'bypassDocumentValidation' ] }, { resource: { db: 'products', collection: '' }, actions: [ 'changeStream', 'collStats', 'compactStructuredEncryptionData', ... ] }, ... ] } ], ok: 1 }
데이터베이스에 대한 모든 사용자 정의 역할 및 기본 제공 역할 보기
다음 작업은 내장 제공 역할과 사용자 정의 역할을 모두 포함하여 명령이 실행되는 데이터베이스 의 모든 역할을 반환합니다.
db.runCommand( { rolesInfo: 1, showBuiltinRoles: true } )
출력 예시(가독성을 위해 축약됨)
{ roles: [ { role: 'enableSharding', db: 'products', isBuiltin: true, roles: [], inheritedRoles: [] }, { role: 'userAdmin', db: 'products', isBuiltin: true, roles: [], inheritedRoles: [] }, { role: 'read', db: 'products', isBuiltin: true, roles: [], inheritedRoles: [] }, ... ], ok: 1 }
역할에 대한 인증 제한 보기
다음 작업은 products 데이터베이스에서 모든 사용자 정의 역할을 반환하며 인증 제한을 포함합니다.
db.runCommand( { rolesInfo: 1, showAuthenticationRestrictions: true } )
출력 예시:
{ roles: [ { _id: 'products.associate', role: 'associate', db: 'products', roles: [ { role: 'readWrite', db: 'products' } ], authenticationRestrictions: [ [ { clientSource: [ '198.51.100.0' ] } ] ], isBuiltin: false, inheritedRoles: [ { role: 'readWrite', db: 'products' } ], inheritedAuthenticationRestrictions: [ [ { clientSource: [ '198.51.100.0' ] } ] ] } ], ok: 1 }