pub struct Authority<Claims, Algo, ReAuth, Args>{ /* 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,
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,
Sourcepub fn new() -> AuthorityBuilder<Claims, Algo, ReAuth, Args>
pub fn new() -> AuthorityBuilder<Claims, Algo, ReAuth, Args>
Returns a new AuthorityBuilder
.
Sourcepub fn token_signer(&self) -> Option<TokenSigner<Claims, Algo>>where
TokenSigner<Claims, Algo>: Clone,
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.
Sourcepub async fn verify_service_request(
&self,
req: &mut ServiceRequest,
) -> AuthResult<Option<TokenUpdate>>
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§
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>where
<Algo as Algorithm>::SigningKey: Sized + RefUnwindSafe,
ReAuth: RefUnwindSafe,
<Algo as Algorithm>::VerifyingKey: RefUnwindSafe,
Algo: RefUnwindSafe,
Claims: RefUnwindSafe,
Args: RefUnwindSafe,
impl<Claims, Algo, ReAuth, Args> Send for Authority<Claims, Algo, ReAuth, Args>
impl<Claims, Algo, ReAuth, Args> Sync for Authority<Claims, Algo, ReAuth, Args>
impl<Claims, Algo, ReAuth, Args> Unpin for Authority<Claims, Algo, ReAuth, Args>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more