Authorizer

Trait Authorizer 

Source
pub trait Authorizer<Actor, Action, Resource, AllowReason = (), ForbiddenReason = ()> {
    // Required method
    fn check(
        actor: &Actor,
        action: &Action,
        resource: &Resource,
    ) -> AuthorizationDecision<AllowReason, ForbiddenReason>;
}
Expand description

An authorization check.

§Type parameters

  • Actor: Type for who would perform the action (e.g. User).
  • Action: Type for what would be performed (e.g. DeletePost).
  • Resource: Type for the target of the action (e.g. Post).
  • AllowReason: (Optional) Type of the allowed reason returned on an Allowed decision. Defaults to ().
  • ForbiddenReason: (Optional) Type of forbidden reason returned on a Forbidden decision. Defaults to ().

Required Methods§

Source

fn check( actor: &Actor, action: &Action, resource: &Resource, ) -> AuthorizationDecision<AllowReason, ForbiddenReason>

Perform the authorization check.

  • actor: Reference to who would perform the action on the resource
  • action: Reference to what would be performed by the actor on the resource
  • resource: Reference to the target of the action performed by the actor

Returns an AuthorizationDecision that will be either allowed or forbidden and carrying optional reason data.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§