| Crates.io | v_authorization |
| lib.rs | v_authorization |
| version | 0.5.1 |
| created_at | 2020-11-28 18:10:03.322184+00 |
| updated_at | 2025-07-09 18:17:28.919283+00 |
| description | authorization lib |
| homepage | |
| repository | https://github.com/semantic-machines/v_authorization |
| max_upload_size | |
| id | 317505 |
| size | 274,742 |
Rust library for access control and authorization with support for complex group hierarchies and flexible permission systems.
v_authorization is a powerful authorization library designed to check user access rights to resources. The library supports:
AllResourcesGroup[dependencies]
v_authorization = "0.4.0"
use v_authorization::{authorize, Storage, Trace};
// Implement Storage trait for your database
struct MyStorage;
impl Storage for MyStorage {
fn get(&mut self, key: &str) -> io::Result<Option<String>> {
// Your implementation for data retrieval
}
fn decode_rec_to_rights(&self, src: &str, result: &mut Vec<ACLRecord>) -> (bool, Option<DateTime<Utc>>) {
// Your implementation for decoding rights
}
// ... other methods
}
// Check access
let mut storage = MyStorage;
let mut trace = Trace { /* ... */ };
let access = authorize(
"document123", // Resource ID
"user456", // User ID
2, // Requested rights (Read = 2)
&mut storage, // Storage implementation
&mut trace // Tracing (optional)
)?;
if access & 2 == 2 {
println!("Read access granted");
} else {
println!("Access denied");
}
use v_authorization::trace;
let trace_info = trace(
"document123",
"user456",
2,
&mut storage
)?;
if let Some(trace_json) = trace_info.finalize() {
println!("Detailed trace:\n{}", trace_json);
}
The library uses the following prefixes for storage keys:
P - permissions (Permissions)M - group membership (Membership)F - access filters (Filters)This project is distributed under the MIT license.