alibi_plugins/sso/
provider_limit.rs1use alibi_core::{AuthResult, wire::UserView};
3use std::sync::Arc;
4
5#[async_trait::async_trait]
6pub trait SsoProviderLimitResolver: Send + Sync {
7 async fn limit(&self, user: UserView) -> AuthResult<f64>;
9}
10
11#[derive(Clone)]
12pub struct SsoProviderLimit(pub Arc<dyn SsoProviderLimitResolver>);
13impl std::fmt::Debug for SsoProviderLimit {
14 fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15 formatter
16 .debug_struct("SsoProviderLimit")
17 .finish_non_exhaustive()
18 }
19}
20
21#[expect(
22 clippy::cast_precision_loss,
23 reason = "the reference compares collection length as a JavaScript number"
24)]
25pub(super) fn reached(count: usize, limit: f64) -> bool {
26 count as f64 >= limit
27}