about summary refs log tree commit diff
path: root/kittybox-rs/src/indieauth/backend.rs
blob: f420db9e7481805c9409f16d635035cfee7714f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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<()>;
}