| Crates.io | auth-policy |
| lib.rs | auth-policy |
| version | 0.0.2 |
| created_at | 2019-04-09 12:11:59.899786+00 |
| updated_at | 2025-11-02 15:05:32.732109+00 |
| description | Rust crate for evaluating authorization decisions against declarative policies |
| homepage | |
| repository | |
| max_upload_size | |
| id | 126813 |
| size | 18,718 |
auth-policy is a work-in-progress Rust crate for evaluating authorization decisions against declarative policies. It aims to make it easy to express who can do what in your application, apply those rules consistently, and audit the decisions that were made.
if statements throughout the codebase.use auth_policy::{
decision::{Decision, Effect},
engine::PolicyEngine,
policy::{Condition, Policy, Target},
request::Request,
};
// Build a policy set that allows team members to read a document they own.
let policy = Policy::builder("document-read")
.target(Target::action("document:read"))
.condition(Condition::equals("resource.owner_id", "actor.id"))
.effect(Effect::Permit)
.build()?;
let engine = PolicyEngine::from_policies([policy]);
let request = Request::new()
.actor_attr("id", "user-123")
.action("document:read")
.resource_attr("owner_id", "user-123");
let decision = engine.evaluate(&request)?;
assert_eq!(decision, Decision::Permit);
⚠️ This crate is in early development. The API above is aspirational and serves as a design target while the crate is being implemented.
[dependencies]
auth-policy = "0.1"
Model your authorization rules using the built-in policy DSL or load them from JSON/YAML.
Instantiate a PolicyEngine, feed it the incoming request, and handle the returned decision.
The project is at an early prototyping stage. Feel free to open issues to discuss design questions or submit pull requests that move the proposed functionality forward. Consistent formatting (cargo fmt) and test coverage (cargo test) keep the codebase healthy.
Distributed under the MIT license. See LICENCE for details.