use std::fmt::Debug;
use std::net::IpAddr;
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use systemprompt_identifiers::{SessionId, UserId};
use super::{GatedIdentity, SsoError};
#[derive(Debug, Clone, Copy)]
pub struct SsoLoginSuccess<'a> {
pub provider_id: &'a str,
pub issuer: &'a str,
pub user_id: &'a UserId,
pub session_id: &'a SessionId,
pub identity: &'a GatedIdentity,
pub created: bool,
pub ip: Option<IpAddr>,
}
#[derive(Debug, Clone, Copy)]
pub struct SsoLoginRefused<'a> {
pub provider_id: &'a str,
pub issuer: &'a str,
pub reason: &'static str,
pub email: Option<&'a str>,
pub external_sub: Option<&'a str>,
pub ip: Option<IpAddr>,
}
#[async_trait]
pub trait AuthEventSink: Send + Sync + Debug {
async fn on_login_success(&self, event: &SsoLoginSuccess<'_>);
async fn on_login_refused(&self, event: &SsoLoginRefused<'_>);
async fn on_logout(&self, _user_id: &UserId, _session_id: &str) {}
}
#[async_trait]
pub trait ReplayGuard: Send + Sync + Debug {
async fn claim(
&self,
scope: &str,
id: &str,
expires_at: DateTime<Utc>,
) -> Result<bool, SsoError>;
}