pub struct AuthenticationService<Claims, Algo, ReAuth, Args>{ /* private fields */ }
Expand description
A wrapper around the Authority
which can be passed to the wrap
function of a App
/Scope
or Resource
.
§Example
use actix_jwt_auth_middleware::{TokenSigner, Authority, AuthenticationService};
use actix_web::{web, App};
use serde::{Serialize, Deserialize};
use ed25519_compact::KeyPair;
use jwt_compact::{alg::Ed25519};
#[derive(Serialize, Deserialize, Clone)]
struct User {
id: u32
}
let KeyPair {
pk: public_key,
sk: secret_key,
} = KeyPair::generate();
let authority = Authority::<User, _, _, _>::new()
.refresh_authorizer(|| async move { Ok(()) })
.token_signer(Some(
TokenSigner::new()
.signing_key(secret_key)
.algorithm(Ed25519)
.build()
.unwrap()
))
.verifying_key(public_key)
.build()
.unwrap();
let app = App::new()
.service(
web::scope("/auth-only")
.wrap(
AuthenticationService::new(authority.clone())
)
);
Implementations§
Source§impl<Claims, Algo, ReAuth, Args> AuthenticationService<Claims, Algo, ReAuth, Args>
impl<Claims, Algo, ReAuth, Args> AuthenticationService<Claims, Algo, ReAuth, Args>
Sourcepub fn new(
authority: Authority<Claims, Algo, ReAuth, Args>,
) -> AuthenticationService<Claims, Algo, ReAuth, Args>
pub fn new( authority: Authority<Claims, Algo, ReAuth, Args>, ) -> AuthenticationService<Claims, Algo, ReAuth, Args>
returns a new AuthenticationService
wrapping the Authority
Trait Implementations§
Source§impl<S, Body, Claims, Algo, ReAuth, Args> Transform<S, ServiceRequest> for AuthenticationService<Claims, Algo, ReAuth, Args>where
S: Service<ServiceRequest, Response = ServiceResponse<Body>, Error = Error> + 'static,
Claims: Serialize + DeserializeOwned + 'static,
Algo: Algorithm + Clone + 'static,
Algo::SigningKey: Clone,
Body: MessageBody,
ReAuth: Handler<Args, Output = Result<(), Error>>,
Args: FromRequest + 'static,
impl<S, Body, Claims, Algo, ReAuth, Args> Transform<S, ServiceRequest> for AuthenticationService<Claims, Algo, ReAuth, Args>where
S: Service<ServiceRequest, Response = ServiceResponse<Body>, Error = Error> + 'static,
Claims: Serialize + DeserializeOwned + 'static,
Algo: Algorithm + Clone + 'static,
Algo::SigningKey: Clone,
Body: MessageBody,
ReAuth: Handler<Args, Output = Result<(), Error>>,
Args: FromRequest + 'static,
Source§type Response = <AuthenticationServiceInner<S, Claims, Algo, ReAuth, Args> as Service<ServiceRequest>>::Response
type Response = <AuthenticationServiceInner<S, Claims, Algo, ReAuth, Args> as Service<ServiceRequest>>::Response
Responses produced by the service.
Source§type Transform = AuthenticationServiceInner<S, Claims, Algo, ReAuth, Args>
type Transform = AuthenticationServiceInner<S, Claims, Algo, ReAuth, Args>
The
TransformService
value created by this factorySource§type Future = Ready<Result<<AuthenticationService<Claims, Algo, ReAuth, Args> as Transform<S, ServiceRequest>>::Transform, <AuthenticationService<Claims, Algo, ReAuth, Args> as Transform<S, ServiceRequest>>::InitError>>
type Future = Ready<Result<<AuthenticationService<Claims, Algo, ReAuth, Args> as Transform<S, ServiceRequest>>::Transform, <AuthenticationService<Claims, Algo, ReAuth, Args> as Transform<S, ServiceRequest>>::InitError>>
The future response value.
Source§fn new_transform(&self, service: S) -> Self::Future
fn new_transform(&self, service: S) -> Self::Future
Creates and returns a new Transform component, asynchronously
Auto Trait Implementations§
impl<Claims, Algo, ReAuth, Args> Freeze for AuthenticationService<Claims, Algo, ReAuth, Args>
impl<Claims, Algo, ReAuth, Args> RefUnwindSafe for AuthenticationService<Claims, Algo, ReAuth, Args>where
<Algo as Algorithm>::SigningKey: Sized + RefUnwindSafe,
Claims: RefUnwindSafe,
ReAuth: RefUnwindSafe,
<Algo as Algorithm>::VerifyingKey: RefUnwindSafe,
Algo: RefUnwindSafe,
Args: RefUnwindSafe,
impl<Claims, Algo, ReAuth, Args> Send for AuthenticationService<Claims, Algo, ReAuth, Args>
impl<Claims, Algo, ReAuth, Args> Sync for AuthenticationService<Claims, Algo, ReAuth, Args>
impl<Claims, Algo, ReAuth, Args> Unpin for AuthenticationService<Claims, Algo, ReAuth, Args>
impl<Claims, Algo, ReAuth, Args> UnwindSafe for AuthenticationService<Claims, Algo, ReAuth, Args>where
<Algo as Algorithm>::SigningKey: Sized + RefUnwindSafe,
Claims: UnwindSafe + RefUnwindSafe,
ReAuth: RefUnwindSafe,
<Algo as Algorithm>::VerifyingKey: RefUnwindSafe,
Algo: RefUnwindSafe,
Args: RefUnwindSafe,
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