pub struct RiskEngine {
pub config: RiskEngineConfig,
pub simulated_risks: Arc<RwLock<HashMap<String, Option<f64>>>>,
pub simulated_factors: Arc<RwLock<HashMap<String, HashMap<String, f64>>>>,
}Expand description
Risk engine state
Fields§
§config: RiskEngineConfigConfiguration
simulated_risks: Arc<RwLock<HashMap<String, Option<f64>>>>Simulated risk scores (user_id -> risk_score override)
simulated_factors: Arc<RwLock<HashMap<String, HashMap<String, f64>>>>Simulated risk factors (user_id -> risk_factors override)
Implementations§
Source§impl RiskEngine
impl RiskEngine
Sourcepub fn new(config: RiskEngineConfig) -> Self
pub fn new(config: RiskEngineConfig) -> Self
Create new risk engine
Sourcepub async fn assess_risk(
&self,
user_id: &str,
risk_factors: &HashMap<String, f64>,
) -> RiskAssessment
pub async fn assess_risk( &self, user_id: &str, risk_factors: &HashMap<String, f64>, ) -> RiskAssessment
Assess risk for an authentication request
Sourcepub async fn set_simulated_risk(&self, user_id: String, risk_score: Option<f64>)
pub async fn set_simulated_risk(&self, user_id: String, risk_score: Option<f64>)
Set simulated risk score for a user
Sourcepub async fn set_simulated_factors(
&self,
user_id: String,
factors: HashMap<String, f64>,
)
pub async fn set_simulated_factors( &self, user_id: String, factors: HashMap<String, f64>, )
Set simulated risk factors for a user
Sourcepub async fn clear_simulated_risk(&self, user_id: &str)
pub async fn clear_simulated_risk(&self, user_id: &str)
Clear simulated risk for a user
Trait Implementations§
Source§impl Clone for RiskEngine
impl Clone for RiskEngine
Source§impl Debug for RiskEngine
impl Debug for RiskEngine
Source§impl Default for RiskEngine
impl Default for RiskEngine
Source§impl RiskSimulationEngine for RiskEngine
impl RiskSimulationEngine for RiskEngine
Source§fn set_simulated_risk<'life0, 'async_trait>(
&'life0 self,
user_id: String,
score: Option<f64>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set_simulated_risk<'life0, 'async_trait>(
&'life0 self,
user_id: String,
score: Option<f64>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Set or remove the existing score override.
Source§fn set_simulated_factors<'life0, 'async_trait>(
&'life0 self,
user_id: String,
factors: HashMap<String, f64>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set_simulated_factors<'life0, 'async_trait>(
&'life0 self,
user_id: String,
factors: HashMap<String, f64>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Set the existing per-user factor overrides.
Source§fn clear_simulated_risk<'life0, 'life1, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn clear_simulated_risk<'life0, 'life1, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Clear score and factor overrides for one user.
Source§fn assess_risk<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
factors: &'life2 HashMap<String, f64>,
) -> Pin<Box<dyn Future<Output = RiskAssessment> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn assess_risk<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
factors: &'life2 HashMap<String, f64>,
) -> Pin<Box<dyn Future<Output = RiskAssessment> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Assess risk using the application’s current configuration and overrides.
Auto Trait Implementations§
impl !RefUnwindSafe for RiskEngine
impl !UnwindSafe for RiskEngine
impl Freeze for RiskEngine
impl Send for RiskEngine
impl Sync for RiskEngine
impl Unpin for RiskEngine
impl UnsafeUnpin for RiskEngine
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request