mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 19:59:54 -05:00
### Does this PR have any customer impact? Yes ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Feature ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) No ### Are you introducing any new config? If yes, do you have tests with and without them being set? No ### ChangeLog (Refer [Template](../oss/CHANGELOG.md)) ### Description We've implemented several key improvements to DocumentDB's user management system, with a focus on enhancing the `usersInfo` command to support privilege information display. ### Feature Overview - Added support for the `showPrivileges` flag in `usersInfo` command - When enabled, user information responses now include detailed privilege documents - Privileges are organized by resource and action, similar to MongoDB's privilege format ### Implementation Details 1. **Privilege Data Structures** - Created predefined privilege sets for each role type (readOnly, readWrite, clusterAdmin) - Designed efficient merging of privilege sets with hash-based deduplication 2. **GUC Configuration** - Added `EnableUsersInfoPrivileges` boolean GUC to control feature availability 3. **Command Flow** - Parse `showPrivileges` flag from incoming BSON documents - When flag is true and GUC is enabled, append privilege array to user documents - Privileges include resource targets (cluster/database/collection) and action lists 4. **Memory Optimization** - Implemented hash-based privilege merging to avoid duplicate entries - Proper memory management with PostgreSQL allocation functions This functionality supports the `connectionStatus` command, which requires authenticated user privileges. We will also support `dbowner` and `root` roles, which will come in a follow-up PR. Related work items: #3852887