Expand description
Application-defined gates and policies over authenticated users.
Applications register their own typed ability contexts while Aurelin owns evaluation, denial responses, hooks, and Axum enforcement.
use aurelin_framework::authorization::Gate;
#[derive(Clone)]
struct User { id: i64 }
#[derive(Clone)]
struct Article { owner_id: i64 }
let mut gates = Gate::<User>::builder();
gates.define("update-article", |user: User, article: Article| async move {
user.id == article.owner_id
});
let gates = gates.build();
let user = User { id: 1 };
let article = Article { owner_id: 1 };
gates
.for_user(Some(&user))
.authorize("update-article", &article)
.await?;Structs§
- Authorization
Response - The result of evaluating an authorization ability.
- Authorize
Layer - A route layer that authorizes an ability using the current
axum-loginsession. - Gate
- A shared registry of application-defined authorization abilities.
- Gate
Builder - Builds an immutable authorization gate registry.
- Gate
Evaluated - The result of a gate check, before the default denial is applied.
- Policy
Registrar - Registers abilities belonging to one application policy.
- User
Gate - A request-oriented view of a gate registry for one user or guest.
Enums§
- Authorization
Error - An authorization denial or invalid gate invocation.
- Gate
Error - A gate was invoked with an incompatible typed context.
Traits§
- Into
Authorization Response - Convert a policy result into an authorization response.
- Policy
- An application policy that registers typed abilities and optional pre-authorization.