# RBAC-System-Cpp **Repository Path**: hzh5480248/RBAC-System-Cpp ## Basic Information - **Project Name**: RBAC-System-Cpp - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-11-17 - **Last Updated**: 2025-11-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # RBAC System (C++) A modular and extensible **Role-Based Access Control (RBAC)** system built with modern C++20. It models hierarchical permissions, custom and standard actions, and user-level overrides. Designed with SOLID principles, this system enables flexible and fine-grained access control for applications that require complex permission logic. --- ## ๐Ÿ“ฆ Features - โœ… Standard CRUD Actions (`Create`, `Read`, `Update`, `Delete`) - โœ… Custom Actions (e.g., `AssignRole`, `ResetPassword`) - โœ… Hierarchical structure: `Role โ†’ PermissionGroup โ†’ Entity` - โœ… Per-user permission overrides - โœ… JSON-driven configuration - โœ… Clear code separation: headers + source files - โœ… Unit tested with GoogleTest - โœ… CMake-based build system (Linux-first, Arch verified) --- ## ๐Ÿ—‚ Project Structure ``` rbac-system/ โ”œโ”€โ”€ include/ # Header files (API, data structures) โ”‚ โ”œโ”€โ”€ ActionSet.hpp โ”‚ โ”œโ”€โ”€ Entity.hpp โ”‚ โ”œโ”€โ”€ PermissionGroup.hpp โ”‚ โ”œโ”€โ”€ Role.hpp โ”‚ โ”œโ”€โ”€ Override.hpp โ”‚ โ”œโ”€โ”€ Evaluator.hpp โ”‚ โ””โ”€โ”€ JsonLoader.hpp โ”œโ”€โ”€ src/ # Implementations โ”‚ โ”œโ”€โ”€ ActionSet.cpp โ”‚ โ”œโ”€โ”€ Entity.cpp โ”‚ โ”œโ”€โ”€ PermissionGroup.cpp โ”‚ โ”œโ”€โ”€ Role.cpp โ”‚ โ”œโ”€โ”€ Override.cpp โ”‚ โ”œโ”€โ”€ Evaluator.cpp โ”‚ โ””โ”€โ”€ JsonLoader.cpp โ”œโ”€โ”€ tests/ # GTest-based unit tests โ”‚ โ””โ”€โ”€ test_permissions.cpp โ”œโ”€โ”€ main.cpp # Example usage / demo โ”œโ”€โ”€ CMakeLists.txt # Build configuration โ””โ”€โ”€ README.md # You are here ``` --- ## โš™๏ธ Build Instructions (Linux / Arch) 1. **Install dependencies**: ```bash sudo pacman -S cmake gtest nlohmann-json ``` 2. **Build the project**: ```bash mkdir build && cd build cmake .. make ``` 3. **Run the demo**: ```bash ./rbac-system ``` 4. **Run unit tests**: ```bash ctest ``` --- ## ๐Ÿงช Example Output ```json { "standard": ["Create"], "custom": ["ResetPassword"] } ``` This result shows that for the `Employees` entity, the user has a custom override granting only `Create` and `ResetPassword`, despite their default role having broader access. --- ## TODO - [ ] Add more testing coverage --- ## ๐Ÿ” Future Improvements - [ ] CLI tool or REST API wrapper - [ ] Persistence layer for user/role storage - [ ] Web-based management UI - [ ] More comprehensive test coverage - [ ] Permission inheritance or rule engine --- ## ๐Ÿค Contributions Pull requests and suggestions are welcome. If you're interested in extending this into a complete access control service, feel free to fork and evolve! --- ## ๐Ÿง  License MIT โ€” free to use and modify.