Struct Authority

Source
pub struct Authority<Claims, Algo, ReAuth, Args>
where Algo: Algorithm + Clone, Algo::SigningKey: Clone,
{ /* private fields */ }
Expand description

The Authority handles the process of authorizing service requests in this crate.

It holds many configuration options to enable/disable specific authorization methods as well as the automatic renewal of JWTs.

§Example

let authority = Authority::<(), Ed25519, _, _>::new()
    .refresh_authorizer(|| async move { Ok(()) })
    .token_signer(Some(
        TokenSigner::new()
            .signing_key(secret_key)
            .algorithm(Ed25519)
            .build()
            .expect(""),
    ))
    .verifying_key(public_key)
    .build()?;

Please refer to the AuthorityBuilder for a detailed description of options available on this struct.

Implementations§

Source§

impl<Claims, Algo, ReAuth, Args> Authority<Claims, Algo, ReAuth, Args>
where Claims: Serialize + DeserializeOwned + 'static, Algo: Algorithm + Clone, Algo::SigningKey: Clone, ReAuth: Handler<Args, Output = Result<(), Error>>, Args: FromRequest,

Source

pub fn new() -> AuthorityBuilder<Claims, Algo, ReAuth, Args>

Returns a new AuthorityBuilder.

Source

pub fn token_signer(&self) -> Option<TokenSigner<Claims, Algo>>
where TokenSigner<Claims, Algo>: Clone,

Returns a Clone of the token_signer field on the Authority.

Source

pub async fn verify_service_request( &self, req: &mut ServiceRequest, ) -> AuthResult<Option<TokenUpdate>>

Use by the actual middleware, which is hidden from the docs, in order to verify an incoming request and ether hand it of to protected services or deny the request by return a wrapped AuthError.

Trait Implementations§

Source§

impl<Claims: Clone, Algo, ReAuth: Clone, Args: Clone> Clone for Authority<Claims, Algo, ReAuth, Args>
where Algo: Algorithm + Clone + Clone, Algo::SigningKey: Clone, Algo::VerifyingKey: Clone,

Source§

fn clone(&self) -> Authority<Claims, Algo, ReAuth, Args>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<Claims, Algo, ReAuth, Args> Freeze for Authority<Claims, Algo, ReAuth, Args>
where <Algo as Algorithm>::SigningKey: Sized + Freeze, ReAuth: Freeze, <Algo as Algorithm>::VerifyingKey: Freeze, Algo: Freeze,

§

impl<Claims, Algo, ReAuth, Args> RefUnwindSafe for Authority<Claims, Algo, ReAuth, Args>

§

impl<Claims, Algo, ReAuth, Args> Send for Authority<Claims, Algo, ReAuth, Args>
where <Algo as Algorithm>::SigningKey: Sized + Send, ReAuth: Send, <Algo as Algorithm>::VerifyingKey: Send, Algo: Send, Claims: Send, Args: Send,

§

impl<Claims, Algo, ReAuth, Args> Sync for Authority<Claims, Algo, ReAuth, Args>
where <Algo as Algorithm>::SigningKey: Sized + Sync, ReAuth: Sync, <Algo as Algorithm>::VerifyingKey: Sync, Algo: Sync, Claims: Sync, Args: Sync,

§

impl<Claims, Algo, ReAuth, Args> Unpin for Authority<Claims, Algo, ReAuth, Args>
where <Algo as Algorithm>::SigningKey: Sized + Unpin, ReAuth: Unpin, <Algo as Algorithm>::VerifyingKey: Unpin, Algo: Unpin, Claims: Unpin, Args: Unpin,

§

impl<Claims, Algo, ReAuth, Args> UnwindSafe for Authority<Claims, Algo, ReAuth, Args>
where <Algo as Algorithm>::SigningKey: Sized + UnwindSafe, ReAuth: UnwindSafe, <Algo as Algorithm>::VerifyingKey: UnwindSafe, Algo: UnwindSafe, Claims: UnwindSafe, Args: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,