AuthorizerWithContext

Trait AuthorizerWithContext 

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

An authorization check with extra context.

§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).
  • Context: Type for any additional data needed to make the decision
  • 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_with_context( actor: &Actor, action: &Action, resource: &Resource, context: &Context, ) -> AuthorizationDecision<AllowReason, ForbiddenReason>

Perform the authorization check given extra context.

  • actor: Reference to who would perform the action on the resource
  • action: Reference to what would be performed by the actor
  • resource: Reference to the target of the action
  • context: Reference to the extra data needed for this check

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§