Skip to main content

Authorizer

Trait Authorizer 

pub trait Authorizer<C>:
    Send
    + Sync
    + 'static {
    type Error: Send + 'static;

    // Required method
    fn authorize(
        &self,
        credentials: C,
    ) -> impl Future<Output = AuthorizeResult<C, Self::Error>> + Send;
}
Available on crate feature net only.
Expand description

The Authorizer trait is used to determine if the given credentials are authorized.

Required Associated Types§

type Error: Send + 'static

Returned in case the credentials are not authorized.

Required Methods§

fn authorize( &self, credentials: C, ) -> impl Future<Output = AuthorizeResult<C, Self::Error>> + Send

Authorize the given credentials.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

§

impl<C> Authorizer<C> for ()
where C: Send + 'static,

§

type Error = Unauthorized

§

async fn authorize( &self, credentials: C, ) -> AuthorizeResult<C, <() as Authorizer<C>>::Error>

§

impl<C> Authorizer<C> for bool
where C: Send + 'static,

§

type Error = Unauthorized

§

async fn authorize( &self, credentials: C, ) -> AuthorizeResult<C, <bool as Authorizer<C>>::Error>

§

impl<const N: usize, A, C> Authorizer<C> for [A; N]
where A: Authorizer<C>, C: Send + Sync + 'static,

Authorizes the credentials which any of its authorizers authorizes.

An empty list rejects all credentials. Wrap an Authorizer in an Option for authentication that is not required when nothing is configured.

§

type Error = AuthorizerListError<<A as Authorizer<C>>::Error>

§

async fn authorize( &self, credentials: C, ) -> AuthorizeResult<C, <[A; N] as Authorizer<C>>::Error>

Implementors§

§

impl<A, C> Authorizer<C> for Arc<A>
where A: Authorizer<C>, C: Send + 'static,

§

type Error = <A as Authorizer<C>>::Error

§

impl<A, C> Authorizer<C> for HttpAuthorizer<A, C>
where A: Authorizer<C>, <A as Authorizer<C>>::Error: Debug, C: Credentials + Send + 'static,

§

impl<A, C> Authorizer<C> for Option<A>
where A: Authorizer<C>, C: Send + 'static,

None requires no authentication and authorizes all credentials; Some delegates to its Authorizer.

Use it to express “no authorizer configured means open”, as an empty list of authorizers rejects all credentials.

§

type Error = <A as Authorizer<C>>::Error

§

impl<A, C> Authorizer<C> for Vec<A>
where A: Authorizer<C>, C: Send + Sync + 'static,

Authorizes the credentials which any of its authorizers authorizes.

An empty list rejects all credentials. Wrap an Authorizer in an Option for authentication that is not required when nothing is configured.

§

impl<C> Authorizer<C> for StaticAuthorizer<C>
where C: PartialEq + Send + Sync + 'static,

§

impl<F, Fut, E, C> Authorizer<C> for F
where F: Fn(C) -> Fut + Send + Sync + 'static, Fut: Future<Output = AuthorizeResult<C, E>> + Send + 'static, E: Send + 'static, C: Send + 'static,

§

type Error = E