1use async_trait::async_trait;
2
3use shield::{Storage, StorageError, User};
4
5use crate::{
6 connection::{CreateOauthConnection, OauthConnection, UpdateOauthConnection},
7 provider::OauthProvider,
8};
9
10#[async_trait]
11pub trait OauthStorage<U: User>: Storage<U> + Sync {
12 async fn oauth_providers(&self) -> Result<Vec<OauthProvider>, StorageError>;
13
14 async fn oauth_provider_by_id_or_slug(
15 &self,
16 provider_id: &str,
17 ) -> Result<Option<OauthProvider>, StorageError>;
18
19 async fn oauth_connection_by_id(
20 &self,
21 connection_id: &str,
22 ) -> Result<Option<OauthConnection>, StorageError>;
23
24 async fn oauth_connection_by_identifier(
25 &self,
26 provider_id: &str,
27 identifier: &str,
28 ) -> Result<Option<OauthConnection>, StorageError>;
29
30 async fn create_oauth_connection(
31 &self,
32 connection: CreateOauthConnection,
33 ) -> Result<OauthConnection, StorageError>;
34
35 async fn update_oauth_connection(
36 &self,
37 connection: UpdateOauthConnection,
38 ) -> Result<OauthConnection, StorageError>;
39
40 async fn delete_oauth_connection(&self, connection_id: &str) -> Result<(), StorageError>;
41}