axum_oidc_client/
auth_cache.rs1use futures_util::future::BoxFuture;
2
3use crate::auth_session::AuthSession;
4use crate::errors::Error;
5
6pub trait AuthCache {
7 fn get_code_verifier(
8 &self,
9 challenge_state: &str,
10 ) -> BoxFuture<'_, Result<Option<String>, Error>>;
11 fn set_code_verifier(
12 &self,
13 challenge_state: &str,
14 code_verifier: &str,
15 ) -> BoxFuture<'_, Result<(), Error>>;
16 fn invalidate_code_verifier(&self, challenge_state: &str) -> BoxFuture<'_, Result<(), Error>>;
17
18 fn get_auth_session(&self, id: &str) -> BoxFuture<'_, Result<Option<AuthSession>, Error>>;
19 fn set_auth_session(&self, id: &str, session: AuthSession) -> BoxFuture<'_, Result<(), Error>>;
20 fn invalidate_auth_session(&self, id: &str) -> BoxFuture<'_, Result<(), Error>>;
21 fn extend_auth_session(&self, id: &str, ttl: i64) -> BoxFuture<'_, Result<(), Error>>;
22}
23
24#[cfg(test)]
25mod tests {
26 use super::*;
27
28 #[test]
30 fn test_dyn_compatible() {
31 fn accepts_trait_object(_cache: Box<dyn AuthCache>) {
32 }
34
35 fn accepts_ref_trait_object(_cache: &dyn AuthCache) {
36 }
38
39 let _ = accepts_trait_object;
41 let _ = accepts_ref_trait_object;
42 }
43}