casbin / casbin-cpp

An authorization library that supports access control models like ACL, RBAC, ABAC in C/C++
https://casbin.org
Apache License 2.0
227 stars 62 forks source link

Porting Casbin-CPP to Real-Time Operating Systems (RTOS) #229

Open hsluoyz opened 1 year ago

hsluoyz commented 1 year ago

Is your feature request related to a problem? Please describe.

Many RTOS platforms (e.g., FreeRTOS, AliOS Things, TencentOS-tiny, LiteOS) are implemented in C language. To integrate Casbin into RTOS environments for execution and invocation by other modules, we need to first compile Casbin-CPP (C version) within the RTOS. The porting process will need to address several challenges:

  1. Compiler compatibility: As RTOS usually runs on embedded devices, a specific compiler and toolchain might be required to compile and link the code. We need to ensure that the Casbin-CPP library is compatible with the compiler and toolchain used by the target RTOS.
  2. Resource constraints: Embedded devices and RTOS often operate under resource-constrained environments, such as limited memory and storage space. Casbin-CPP may require optimizations to reduce resource usage, e.g., adjusting memory allocation strategies, reducing global variable usage, and optimizing data structures.
  3. System library dependencies: Casbin-CPP may rely on some system libraries, such as the C++ standard library and POSIX API. In an RTOS environment, these libraries may not be fully available or provide limited functionality. Alternative solutions or custom implementations for missing features may be necessary.
  4. Thread safety: Casbin-CPP might not have been designed with thread safety in mind for RTOS environments. Modifications to the library may be necessary to ensure its safety in a multi-threaded environment, such as adding locks and using atomic operations.
  5. Filesystem and persistence: Casbin typically loads policies from files and supports persisting policies to files. However, traditional file systems might not be available in RTOS environments. This may require modifications to the policy loading and persistence parts of Casbin-CPP to adapt to the RTOS environment, e.g., storing policy data in memory or using non-filesystem-based persistence methods.

Describe the solution you'd like

We would like to explore and implement the necessary modifications and optimizations to make Casbin-CPP compatible with RTOS environments. This may include addressing the challenges listed above, such as compiler compatibility, resource constraints, system library dependencies, thread safety, and filesystem adaptations.

Describe alternatives you've considered

An alternative solution would be to implement a new library specifically designed for RTOS environments. However, porting the existing Casbin-CPP library would allow for better code reusability and maintainability.

Additional context

This feature request is in response to the growing demand for integrating Casbin into IoT devices and other embedded systems running RTOS. By porting Casbin-CPP to RTOS, we can expand the library's applicability and make it a more versatile solution for access control and authorization in various contexts.

casbin-bot commented 1 year ago

@EmperorYP7 @sheny1xuan @cs1137195420