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§fn clone(&self) -> RiskEngine
fn clone(&self) -> RiskEngine
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RiskEngine
impl Debug for RiskEngine
Auto Trait Implementations§
impl Freeze for RiskEngine
impl !RefUnwindSafe for RiskEngine
impl Send for RiskEngine
impl Sync for RiskEngine
impl Unpin for RiskEngine
impl !UnwindSafe 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