dittolive_ditto/identity/auth/login_provider.rs
1use std::time::Duration;
2
3use crate::identity::DittoAuthenticator;
4
5/// Implement this trait for a type in order to use
6/// [`DittoConfigConnect::Server`] mode with the old callback-based
7/// authentication API.
8///
9/// **v5 note:** This trait is superseded by [`DittoAuthExpirationHandler`] in v5.
10/// Use `DittoAuthExpirationHandler` with [`DittoConfigConnect::Server`] mode instead.
11///
12/// [`DittoConfigConnect::Server`]: crate::DittoConfigConnect::Server
13/// [`DittoAuthExpirationHandler`]: crate::DittoAuthExpirationHandler
14pub trait DittoAuthenticationEventHandler: Send + Sync {
15 /// This will be called when you need to authenticate.
16 /// Usually it will involve a call to `auth.login`.
17 fn authentication_required(&self, auth: DittoAuthenticator);
18
19 /// Allows for custom behavior hooks when authentication is expiring
20 fn authentication_expiring_soon(&self, auth: DittoAuthenticator, seconds_remaining: Duration);
21}