diff options
Diffstat (limited to 'kittybox-rs/src/indieauth/backend.rs')
-rw-r--r-- | kittybox-rs/src/indieauth/backend.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/kittybox-rs/src/indieauth/backend.rs b/kittybox-rs/src/indieauth/backend.rs new file mode 100644 index 0000000..f420db9 --- /dev/null +++ b/kittybox-rs/src/indieauth/backend.rs @@ -0,0 +1,21 @@ +use std::collections::HashMap; + +use kittybox_indieauth::{ + AuthorizationRequest, TokenData +}; + +type Result<T> = std::io::Result<T>; + +#[async_trait::async_trait] +pub trait AuthBackend: Clone + Send + Sync + 'static { + async fn create_code(&self, data: AuthorizationRequest) -> Result<String>; + async fn get_code(&self, code: &str) -> Result<Option<AuthorizationRequest>>; + async fn create_token(&self, data: TokenData) -> Result<String>; + async fn get_token(&self, token: &str) -> Result<Option<TokenData>>; + async fn list_tokens(&self, website: url::Url) -> Result<HashMap<String, TokenData>>; + async fn revoke_token(&self, token: &str) -> Result<()>; + async fn create_refresh_token(&self, data: TokenData) -> Result<String>; + async fn get_refresh_token(&self, token: &str) -> Result<Option<TokenData>>; + async fn list_refresh_tokens(&self, website: url::Url) -> Result<HashMap<String, TokenData>>; + async fn revoke_refresh_token(&self, token: &str) -> Result<()>; +} |