v-authorization
Rust library for access control and authorization with support for complex group hierarchies and flexible permission systems.
Description
v_authorization is a powerful authorization library designed to check user access rights to resources. The library supports:
- User groups with hierarchical structure
- Object groups for resource organization
- Permission inheritance through multi-level hierarchies
- Exclusive rights for special access cases
- Access filtering with dynamic restrictions
- Detailed tracing of decision-making process
- Caching for performance optimization
Key Features
Access Permission Types
- Create (C) - resource creation
- Read (R) - data reading
- Update (U) - modifying existing data
- Delete (D) - resource deletion
- Deny permissions - explicit access denial
Group-based Authorization
- Users can belong to multiple groups
- Groups can be nested within other groups
- Rights are inherited through group hierarchies
- Support for exclusive groups for special cases
Object Groups
- Resources can belong to object groups
- Permissions are set on object groups
- Support for global
AllResourcesGroup
Quick Start
Adding to Project
[]
= "0.4.0"
Basic Usage
use ;
// Implement Storage trait for your database
;
// Check access
let mut storage = MyStorage;
let mut trace = Trace ;
let access = authorize?;
if access & 2 == 2 else
Tracing for Debugging
use trace;
let trace_info = trace?;
if let Some = trace_info.finalize
Architecture
Working Process
- Find user groups - determine all groups the user belongs to
- Find object groups - determine groups the requested resource belongs to
- Check permissions - match rights between user and object groups
- Apply filters - apply additional access restrictions
- Return result - final access rights as a bitmask
Data Format
The library uses the following prefixes for storage keys:
P- permissions (Permissions)M- group membership (Membership)F- access filters (Filters)
Documentation
- Authorization Algorithm - detailed logic description
- Developer Documentation - technical documentation
- JavaScript Implementation - reference JS implementation
- Tests - test coverage description
Performance
- Caching support to minimize database queries
- Optimization of recursive queries through group hierarchies
- Recursion depth limits to prevent infinite loops
- Efficient bitwise arithmetic for permission handling
Security
- Explicit handling of exclusive rights
- Input data validation
- Overflow protection for deep recursion
- Support for deny permissions
Compatibility
- Rust: 2021 edition
- Dependencies: chrono, chrono-tz, serde_json
License
This project is distributed under the MIT license.