Installation
Prerequisites
- Rust 1.70 or later
- Cargo (included with Rust)
Installing Rust
If you don’t have Rust installed:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Adding as a Dependency
acls-rs
For the algebraic access control foundation:
[dependencies]
acls-rs = "0.1"
# With serde support for JSON serialization
acls-rs = { version = "0.1", features = ["serde"] }
hbac-rs
For HBAC rule evaluation:
[dependencies]
hbac-rs = "0.1"
acls-rs = "0.1" # Required dependency
# With serde and caching support
hbac-rs = { version = "0.1", features = ["serde"] }
abac-rs
For ABAC rule evaluation:
[dependencies]
abac-rs = "0.1"
acls-rs = "0.1" # Required dependency
# With serde support
abac-rs = { version = "0.1", features = ["serde"] }
perf-testing
For performance testing and benchmarking:
[dependencies]
perf-testing = "0.1"
Building from Source
Clone the repository:
git clone https://codeberg.org/abbra/aci-validator.git bac-rules
cd bac-rules
Build all crates:
cargo build --release
Build specific crate:
cargo build --package hbac-rs --release
cargo build --package abac-rs --release
cargo build --package acls-rs --release
cargo build --package perf-testing --release
Running Tests
# Test all crates
cargo test --workspace
# Test specific crate
cargo test --package hbac-rs
cargo test --package abac-rs
cargo test --package acls-rs
cargo test --package perf-testing
Performance Testing CLI
Build the bac-perf CLI tool:
cargo build --release --package perf-testing
The binary will be at target/release/bac-perf.
Verification
Verify installation by running examples:
# acls-rs example
cargo run --package acls-rs --example basic_usage
# hbac-rs example
cargo run --package hbac-rs --example basic_usage
# abac-rs example
cargo run --package abac-rs --example basic_usage
# Performance test
./target/release/bac-perf --help
Python Bindings
All three crates (acls-rs, hbac-rs, abac-rs) provide Python bindings via PyO3.
Prerequisites
- Python 3.8 or higher
- Rust 1.70 or higher (for building from source)
- maturin - Python/Rust build tool
Quick Setup
We recommend using a virtual environment:
# Create and activate virtual environment
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install maturin
pip install maturin
Installing Python Bindings
Development mode (recommended for local development):
# Install all three packages
cd crates/acls-python && maturin develop && cd ../..
cd crates/hbac-python && maturin develop && cd ../..
cd crates/abac-python && maturin develop && cd ../..
Production wheels:
# Build wheels
cd crates/acls-python
maturin build --release --out ../../dist/
cd ../hbac-python
maturin build --release --out ../../dist/
cd ../abac-python
maturin build --release --out ../../dist/
cd ../..
# Install from wheels
pip install dist/acls_rs-*.whl
pip install dist/hbac_rs-*.whl
pip install dist/abac_rs-*.whl
Verifying Installation
# Test acls-rs bindings
python3 crates/acls-python/examples/basic_usage.py
# Test hbac-rs bindings
python3 crates/hbac-python/examples/basic_usage.py
# Test abac-rs bindings
python3 crates/abac-python/examples/basic_usage.py
Quick Test
# Test in Python REPL
python3
>>> from hbac_rs import HbacRuleBuilder, HbacPolicy, HbacRequest, Subject
>>> rule = HbacRuleBuilder("test").user("alice").host_category_all().service_category_all().enabled(True).build()
>>> policy = HbacPolicy()
>>> policy.add_rule(rule)
<hbac_rs.HbacPolicy object at 0x...>
>>> user = Subject("alice")
>>> request = HbacRequest(user, "server", "ssh")
>>> policy.check_access(request)
True
See the Python bindings documentation for detailed API reference:
Platform Support
Tested on:
- Linux (x86_64, aarch64)
- macOS (x86_64, Apple Silicon)
- Windows (x86_64)
The crates are platform-independent pure Rust with no OS-specific dependencies.