actix-web-security 0.1.0

Basic-Auth / OAuth2 easy-to-use authentication modules for actix web
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Utility trait to attach a `UserDetails` object to the request context.

use actix_web::dev::ServiceRequest;
use actix_web::HttpMessage;

use crate::user_details::UserDetails;

/// A helper trait to attch a boxed `UserDetails` object to the request context.
pub trait UserDetailsRequestAttachmentHelper {
    fn attach(&self, user_details: Box<dyn UserDetails>);
}

impl UserDetailsRequestAttachmentHelper for ServiceRequest {
    fn attach(&self, user_details: Box<dyn UserDetails>) {
        self.extensions_mut().insert(user_details);
    }
}