pub struct AuthenticationService<Claims, Algo, ReAuth, Args>where
Algo: Algorithm + Clone,
Algo::SigningKey: Clone,{ /* 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 exonum_crypto::KeyPair;
use jwt_compact::{alg::Ed25519};
#[derive(Serialize, Deserialize, Clone)]
struct User {
id: u32
}
let key_pair = KeyPair::random();
let authority = Authority::<User, _, _, _>::new()
.refresh_authorizer(|| async move { Ok(()) })
.token_signer(Some(
TokenSigner::new()
.signing_key(key_pair.secret_key().clone())
.algorithm(Ed25519)
.build()
.unwrap()
))
.verifying_key(key_pair.public_key().clone())
.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>where
Claims: DeserializeOwned,
Algo: Algorithm + Clone,
Algo::SigningKey: Clone,
impl<Claims, Algo, ReAuth, Args> AuthenticationService<Claims, Algo, ReAuth, Args>where Claims: DeserializeOwned, Algo: Algorithm + Clone, Algo::SigningKey: Clone,
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 = ActixWebError> + 'static,
Claims: Serialize + DeserializeOwned + 'static,
Algo: Algorithm + Clone + 'static,
Algo::SigningKey: Clone,
Body: MessageBody,
ReAuth: Handler<Args, Output = Result<(), ActixWebError>>,
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 = ActixWebError> + 'static, Claims: Serialize + DeserializeOwned + 'static, Algo: Algorithm + Clone + 'static, Algo::SigningKey: Clone, Body: MessageBody, ReAuth: Handler<Args, Output = Result<(), ActixWebError>>, Args: FromRequest + 'static,
§type Response = <AuthenticationMiddleware<S, Claims, Algo, ReAuth, Args> as Service<ServiceRequest>>::Response
type Response = <AuthenticationMiddleware<S, Claims, Algo, ReAuth, Args> as Service<ServiceRequest>>::Response
Responses produced by the service.
§type Transform = AuthenticationMiddleware<S, Claims, Algo, ReAuth, Args>
type Transform = AuthenticationMiddleware<S, Claims, Algo, ReAuth, Args>
The
TransformService
value created by this factory§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